AndyCompanyZ
Registered User.
- Local time
- Today, 05:16
- Joined
- Mar 24, 2011
- Messages
- 223
I am trying to write some code that will update a table if there is no record currently there.
I am using Dlookup to check the table tblCourseDelegate to see if there is a delegate who is scheduled on an event and if not then to schedule them. If they are already scheduled then I want a message box to alert the user. The query I mention works fine in isolation but the code I have throws up an "Expected: list seperator or )" error and points to the EventID after the AND (highlighted in red).
Private Sub btnScheduleQuery_Click()
On Error GoTo btnScheduleQuery_Click_Err
If DLookup("DelegateID","CourseDelegate","DelegateID="& DelegateID &") AND ("EventID","CourseDelegate","EventID="& EventID &") Then
MsgBox "This delegate id already scheduled for this course"
Else
DoCmd.OpenQuery "EventDel", acViewNormal, acEdit
DoCmd.RunSQL "UPDATE Event SET Event.PlacesAvailable = Event.PlacesAvailable -1 WHERE EventID=forms!CoursesDelegate.cmboEvent.form!EventID;"
btnScheduleQuery_Click_Exit:
Exit Sub
btnScheduleQuery_Click_Err:
MsgBox Error$
Resume btnScheduleQuery_Click_Exit
End Sub
Does anyone know where I'm going wrong please
I am using Dlookup to check the table tblCourseDelegate to see if there is a delegate who is scheduled on an event and if not then to schedule them. If they are already scheduled then I want a message box to alert the user. The query I mention works fine in isolation but the code I have throws up an "Expected: list seperator or )" error and points to the EventID after the AND (highlighted in red).
Private Sub btnScheduleQuery_Click()
On Error GoTo btnScheduleQuery_Click_Err
If DLookup("DelegateID","CourseDelegate","DelegateID="& DelegateID &") AND ("EventID","CourseDelegate","EventID="& EventID &") Then
MsgBox "This delegate id already scheduled for this course"
Else
DoCmd.OpenQuery "EventDel", acViewNormal, acEdit
DoCmd.RunSQL "UPDATE Event SET Event.PlacesAvailable = Event.PlacesAvailable -1 WHERE EventID=forms!CoursesDelegate.cmboEvent.form!EventID;"
btnScheduleQuery_Click_Exit:
Exit Sub
btnScheduleQuery_Click_Err:
MsgBox Error$
Resume btnScheduleQuery_Click_Exit
End Sub
Does anyone know where I'm going wrong please