I keep getting a syntax error everytime I insert a date or time into the DB. I cannont understand what I am doing wrong. Any suggestions?
Thank you
1 Dim conEntry As ADODB.Connectio n
2 Dim datDate As Date
3 Dim strTime As String
4 Dim strEntry As String
5 Dim strInitials As String
6 Dim datDateTime As Date
7 datDate = Date
8 strTime = txtTime.Text
9 strEntry = txtEntry.Text
10 strInitials = UCase(txtInitia ls.Text)
11 datDateTime = Now()
12 'Open a connection to the Database
13 Set conEntry = New ADODB.Connectio n
14 conEntry.Connec tionString = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=C:\DutyL og.mdb; Persist Security Info=False"
15 conEntry.Open
16 'Add entry
17 conEntry.Execut e ("INSERT INTO tblLog (Date, Time, Entry, Initials, DateTime) VALUES (" & _
"#" & datDate & "#, " & _
"'" & strTime & "', " & _
"'" & strEntry & "', " & _
"'" & strInitials & "', " & _
"#" & datDateTime & "#)")
18 'Close the connection to the Database
19 conEntry.Close
Thank you
1 Dim conEntry As ADODB.Connectio n
2 Dim datDate As Date
3 Dim strTime As String
4 Dim strEntry As String
5 Dim strInitials As String
6 Dim datDateTime As Date
7 datDate = Date
8 strTime = txtTime.Text
9 strEntry = txtEntry.Text
10 strInitials = UCase(txtInitia ls.Text)
11 datDateTime = Now()
12 'Open a connection to the Database
13 Set conEntry = New ADODB.Connectio n
14 conEntry.Connec tionString = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=C:\DutyL og.mdb; Persist Security Info=False"
15 conEntry.Open
16 'Add entry
17 conEntry.Execut e ("INSERT INTO tblLog (Date, Time, Entry, Initials, DateTime) VALUES (" & _
"#" & datDate & "#, " & _
"'" & strTime & "', " & _
"'" & strEntry & "', " & _
"'" & strInitials & "', " & _
"#" & datDateTime & "#)")
18 'Close the connection to the Database
19 conEntry.Close
Comment