change simple msgbox to vbYesNo

  • Thread starter serviceman via AccessMonster.com
  • Start date
S

serviceman via AccessMonster.com

I'm bangin' my head on the wall over this one...
Here is the current code:

Private Sub SaveScheduleRecord_Click()
On Error GoTo Err_SaveScheduleRecord_Click
Dim x As Variant
x = DLookup("EVENT_ID", "ATTENDANCE", "ATT_HDR_ID=" & Me.ATT_HDR_ID)
If IsNull(x) = True Then
MsgBox "No Students have been added to this class! Are you sure you want
to save this class and return to the main menu?"
End If
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.Close
DoCmd.OpenForm "Switchboard", acNormal, , , acFormAdd, acWindowNormal

Exit_SaveScheduleRecord_Click:
Exit Sub

Err_SaveScheduleRecord_Click:
'change the code to the one you need
MsgBox "A " & Text15 & " between " & Format(EVENT_ST_TIME, "Medium Time")
& " and " & Format(EVENT_END_TIME, "Medium Time") & " on " & Text17 & " Has
Already been Scheduled for " & EVENT_DAT


Resume Exit_SaveScheduleRecord_Click

End Sub


This works, but I need to get the MsgBox to a vbYesNo type so a user can
either cancel the save and return to the form of Ok the blank subtable and
save the main table record. I KNOW this isn't a big deal, but damned if I can
figure out what I'm missing!
Andy
 
G

Guest

Private Sub SaveScheduleRecord_Click()
On Error GoTo Err_SaveScheduleRecord_Click
Dim x As Variant
x = DLookup("EVENT_ID", "ATTENDANCE", "ATT_HDR_ID=" & Me.ATT_HDR_ID)
If IsNull(x) = True Then
If MsgBox ("No Students have been added to this class! Are you sure you
want
to save this class and return to the main menu?,vbYesNo + vbQuestion) =
vbYes Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.Close
DoCmd.OpenForm "Switchboard", acNormal, , , acFormAdd, acWindowNormal
End If
End If
Exit_SaveScheduleRecord_Click:
Exit Sub

Err_SaveScheduleRecord_Click:
'change the code to the one you need
MsgBox "A " & Text15 & " between " & Format(EVENT_ST_TIME, "Medium Time")
& " and " & Format(EVENT_END_TIME, "Medium Time") & " on " & Text17 & " Has
Already been Scheduled for " & EVENT_DAT


Resume Exit_SaveScheduleRecord_Click

End Sub
 
S

serviceman via AccessMonster.com

Ah Barry,
A million thanks....
Round and round I went 'til you dropped me a line...
Thanks again!
Andy

Barry said:
Private Sub SaveScheduleRecord_Click()
On Error GoTo Err_SaveScheduleRecord_Click
Dim x As Variant
x = DLookup("EVENT_ID", "ATTENDANCE", "ATT_HDR_ID=" & Me.ATT_HDR_ID)
If IsNull(x) = True Then
If MsgBox ("No Students have been added to this class! Are you sure you
want
to save this class and return to the main menu?,vbYesNo + vbQuestion) =
vbYes Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.Close
DoCmd.OpenForm "Switchboard", acNormal, , , acFormAdd, acWindowNormal
End If
End If
Exit_SaveScheduleRecord_Click:
Exit Sub

Err_SaveScheduleRecord_Click:
'change the code to the one you need
MsgBox "A " & Text15 & " between " & Format(EVENT_ST_TIME, "Medium Time")
& " and " & Format(EVENT_END_TIME, "Medium Time") & " on " & Text17 & " Has
Already been Scheduled for " & EVENT_DAT


Resume Exit_SaveScheduleRecord_Click

End Sub
I'm bangin' my head on the wall over this one...
Here is the current code:
[quoted text clipped - 30 lines]
figure out what I'm missing!
Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top