LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.office.developer.vba,microsoft.public.excel.misc,microsoft.public.excel,microsoft.public.fox.helpwanted
external usenet poster
 
Posts: 10
Default Excel VBA - SQL to .dbf date problem - GETTING DESPERATE

Hi,

I've been trying to do some SQL work in VBA to allow people to change
database fields more easily.
I managed to:
extract the data from the file,
change it in excel,
add a new record where the user adds a new row,
start populating this field (with default values as only certain
values are changed in the view the user sees),
crash when trying to populate a date field.

At some point I'm going to try deleting fields (all efforts so far
have failed) but for now, I'm trying to get this date field updated so
that the remaining fields will populate themselves.

Using the UPDATE statement I tried each of the following:

sql_string = "UPDATE prjbat SET dstamp = #" & DStamp & _
"# WHERE (batchno = " & batchno & " AND jobno = "
& Jobno & ")"

sql_string = "UPDATE prjbat SET dstamp = #" & Format(DStamp, "dd-mmm-
yyyy") & _
"# WHERE (batchno = " & batchno & " AND jobno = "
& Jobno & ")"

sql_string = "UPDATE prjbat SET dstamp = '" & DStamp & _
"' WHERE (batchno = " & batchno & " AND jobno = "
& Jobno & ")"

sql_string = "UPDATE prjbat SET dstamp = '" & Format(DStamp, "dd-mmm-
yyyy") & _
"' WHERE (batchno = " & batchno & " AND jobno = "
& Jobno & ")"

sql_string = "UPDATE prjbat SET dstamp = " & DStamp & _
" WHERE (batchno = " & batchno & " AND jobno = " &
Jobno & ")"

sql_string = "UPDATE prjbat SET dstamp = " & Format(DStamp, "dd-mmm-
yyyy") & _
" WHERE (batchno = " & batchno & " AND jobno = " &
Jobno & ")"

sql_string = "UPDATE prjbat SET dstamp = #" & Format(DStamp, "mm/dd/
yy") & _
"# WHERE (batchno = " & batchno & " AND jobno = "
& Jobno & ")"

sql_string = "UPDATE prjbat SET dstamp = """ & Format(DStamp, "mm/dd/
yy") & """" & _
" WHERE (batchno = " & batchno & " AND jobno = " &
Jobno & ")"

sql_string = "UPDATE prjbat SET dstamp = LUPDATE(prjbat)* & _
" WHERE (batchno = " & batchno & " AND jobno = " &
Jobno & ")"

sql_string = "UPDATE prjbat SET dstamp = sysdate" & _
" WHERE (batchno = " & batchno & " AND jobno = " &
Jobno & ")"

sql_string = "UPDATE prjbat SET dstamp = {ts " & DString & "}" & _
" WHERE (batchno = " & batchno & " AND jobno = " &
Jobno & ")"

The format of the dstamp field in the table is mm/dd/yy. I also tried
reading dstamp in in both date and string format, including a date
format which removes the time element ( DATE(year,month,day) ). I just
want a date stamp showing the latest date so am happy for a SQL
function that sticks in the current date.

I'm going insane.
And the next field along is time so I'm sure I'll struggle again.

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculating Problem: Desperate :( cionnaith Excel Worksheet Functions 4 March 10th 10 02:09 AM
Excel VBA - SQL to .dbf date problem - GETTING DESPERATE Erasmus Excel Discussion (Misc queries) 6 July 2nd 07 05:20 PM
Desperate for help in travelling salesman problem! krzys_28 Excel Discussion (Misc queries) 5 April 23rd 06 06:44 PM
DESPERATE FOR HELP ON THIS PROBLEM...please JackR Excel Discussion (Misc queries) 2 March 16th 06 09:08 PM
Excel program help - desperate!!! Felicity Geronimo Excel Programming 1 October 21st 04 02:07 PM


All times are GMT +1. The time now is 11:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"