E
Erasmus
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.
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.