J
Jack1992
Hi,
I am working on a project for booking courses and below is the code I am
using in vba to make error boxes come up:
Option Compare Database
Private Sub btn_book_event_Click()
On Error GoTo Err_btn_book_event_Click
Dim MsgBoxTxt As String
Dim Places As String
Places = DCount("*", "Booking", "[Course ID] = ComboCourse")
If DCount("*", "Booking", "[Course ID]=ComboCourse") < 20 Then
MsgBoxTxt = "Event is Booked." & Places & " places are already booked and
there are " & 20 - Places & " places left."
Else
MsgBoxTxt = "Event is full with " & Places & " places taken out of 20.
Sorry, this Course can not be booked."
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
End If
MsgBox MsgBoxTxt
DoCmd.DoMenuItem acFormBar, acRecordMenu, acSaveRecord, , acMenuVer70
If DCount("*", "Booking", "[Course ID]=ComboCourse and [CustomerID] =
FormCustomerID") >= 1 Then
MsgBoxTxt = "Customer has already been booked on this course"
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
End If
MsgBox MsgBoxTxt
DoCmd.DoMenuItem acFormBar, acRecordMenu, acSaveRecord, , acMenuVer70
Exit_btn_book_event_Click:
Exit Sub
Err_btn_book_event_Click:
MsgBox Err.Description
Resume Exit_btn_book_event_Click
End Sub
Long code but errors occur.
I will click the button to run this, it says the first text box however it
then will say 'You cancelled the previous operation.'
Anyone have any idea why this is happening?
I am working on a project for booking courses and below is the code I am
using in vba to make error boxes come up:
Option Compare Database
Private Sub btn_book_event_Click()
On Error GoTo Err_btn_book_event_Click
Dim MsgBoxTxt As String
Dim Places As String
Places = DCount("*", "Booking", "[Course ID] = ComboCourse")
If DCount("*", "Booking", "[Course ID]=ComboCourse") < 20 Then
MsgBoxTxt = "Event is Booked." & Places & " places are already booked and
there are " & 20 - Places & " places left."
Else
MsgBoxTxt = "Event is full with " & Places & " places taken out of 20.
Sorry, this Course can not be booked."
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
End If
MsgBox MsgBoxTxt
DoCmd.DoMenuItem acFormBar, acRecordMenu, acSaveRecord, , acMenuVer70
If DCount("*", "Booking", "[Course ID]=ComboCourse and [CustomerID] =
FormCustomerID") >= 1 Then
MsgBoxTxt = "Customer has already been booked on this course"
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
End If
MsgBox MsgBoxTxt
DoCmd.DoMenuItem acFormBar, acRecordMenu, acSaveRecord, , acMenuVer70
Exit_btn_book_event_Click:
Exit Sub
Err_btn_book_event_Click:
MsgBox Err.Description
Resume Exit_btn_book_event_Click
End Sub
Long code but errors occur.
I will click the button to run this, it says the first text box however it
then will say 'You cancelled the previous operation.'
Anyone have any idea why this is happening?