This function below is meant to update a date field.
Public Sub complete(id As Integer, completed As String)
Dim dbs As DATABASE
Set dbs = CurrentDb
Dim completedDate As Date
If completed = "Yes" Then
completed = "No"
dbs.Execute "UPDATE TempHI SET Completed = '" & completed & "' WHERE bestId = " & id & ";"
dbs.Execute "UPDATE orderTable SET completed = '" & completed & "' WHERE bestId = " & id & ";"
Else
completed = "Yes"
completedDate = Date
dbs.Execute "UPDATE TempHI SET Completed = '" & completed & "', " & _
"completedDate = " & completedDate & " WHERE bestId = " & id & ";"
dbs.Execute "UPDATE orderTable SET Completed = '" & completed & "', " & _
"completedDate = " & completedDate & " WHERE bestId = " & id & ";"
End If
dbs.Close
End Sub
The problem is that after running this procedure, the field completed contains the date 1905-05-27 instead of today´s date. Very strange...
Can anyone see the reason to this?
Thanks,
/Linus
Public Sub complete(id As Integer, completed As String)
Dim dbs As DATABASE
Set dbs = CurrentDb
Dim completedDate As Date
If completed = "Yes" Then
completed = "No"
dbs.Execute "UPDATE TempHI SET Completed = '" & completed & "' WHERE bestId = " & id & ";"
dbs.Execute "UPDATE orderTable SET completed = '" & completed & "' WHERE bestId = " & id & ";"
Else
completed = "Yes"
completedDate = Date
dbs.Execute "UPDATE TempHI SET Completed = '" & completed & "', " & _
"completedDate = " & completedDate & " WHERE bestId = " & id & ";"
dbs.Execute "UPDATE orderTable SET Completed = '" & completed & "', " & _
"completedDate = " & completedDate & " WHERE bestId = " & id & ";"
End If
dbs.Close
End Sub
The problem is that after running this procedure, the field completed contains the date 1905-05-27 instead of today´s date. Very strange...
Can anyone see the reason to this?
Thanks,
/Linus