beefwellington
Registered User.
- Local time
- Today, 11:20
- Joined
- Jul 27, 2009
- Messages
- 14
Code:
Dim sql As String
sql = "INSERT INTO EquipmentLog (EquipmentID, State, User, Comment, Status, DateTime) VALUES ('" & Me.EquipmentID.Value & "', '" & Me.cboNewState.Value & "', '" & Me.cboUser.Value & "', '" & Me.Comment.Value & "', '" & Me.Status.Value & "', #" & Now() & "#)"
With DoCmd
.SetWarnings False
.RunSQL sql
.SetWarnings True
End With
This is what I currently have but when I click a button on the form to save, I get a VBA error stating the INSERT INTO syntax is incorrect. I noticed if I changed my sql String to:
Code:
sql = "INSERT INTO EquipmentLog (EquipmentID, State, User, Comment, Status) VALUES ('" & Me.EquipmentID.Value & "', '" & Me.cboNewState.Value & "', '" & Me.cboUser.Value & "', '" & Me.Comment.Value & "', '" & Me.Status.Value & "')"
The INSERT INTO query works fine. But I need to time stamp the INSERT. The "DateTime" field name is in my Table as a "Date/Time" type. Am I missing something in my code? It seems like it should work fine but obviously it doesn't. Any help would be appreciated.