Insert into sql error

access7

Registered User.
Local time
Today, 10:49
Joined
Mar 15, 2011
Messages
172
Morning all,

I am hoping someone may be able to shed some light on the following, I am still quite new to writing these and cannot figure out where I have gone wrong... on execute I am getting a syntax error in the INSERT INTO statement... please help :o

Here is the code I have written...

Function BSaveDiaryAction(liContactRef As Integer, lsActionType As String, lsReason As String, lsPassTo As String, lsPriority As String, lsDueDate As String) As Boolean
Dim lsSQL As String

On Error GoTo Oops
lsSQL = ""
lsSQL = lsSQL & " INSERT INTO Tbl_Diary (CompanyRef, ContactRef, ActionType, Reason, PassTo, PassFrom, Priority, DueDate, Complete, Completion Date) "
lsSQL = lsSQL & " VALUES (" & ICompanyRef & ", " & liContactRef & ", '" & lsActionType & "', '" & lsReason & "', '" & lsPassTo & "', '" & SUser & "', '" & lsPriority & "', '" & lsDueDate & "', " & False & ", '" & lsDueDate & "')"

CurrentDb.Execute lsSQL

BSaveDiaryAction = True

Exit Function

Oops:
MsgBox Err.Description

End Function


here are the results in the immediate window...

INSERT INTO Tbl_Diary (CompanyRef, ContactRef, ActionType, Reason, PassTo, PassFrom, Priority, DueDate, Complete, Completion Date) VALUES (0, 30, 'Visit', 'Introduction', 'Ian H', '', 'High', '10/05/2012', False, '10/05/2012')
 
ok, think it may have been my field called completion date - it doesn't have a space, should have been 'completiondate' - seems to be stepping through OK now... will update if I still need help. Thanks if you have read this post :-)
xx
 
BTW. Why are you using strings for dates?
 

Users who are viewing this thread

Back
Top Bottom