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
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')
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
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')