form msgbox

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

Hi,

I have two forms. One form has a calendar, in which a
date range is selected (beginning & ending date), then the
user can click a command button that opens up the second
form. The second form, ClassRegistration, has a pull-down-
menu text box with a query as an control source. The
query for the pull-down text box fills in the ClassID's
that are available for that date range selected on the
first form. (hope this is making a little sense to you)
Also, on the ClassRegistration form I have a subform that
list the class details, such as title, location, etc.

Anyway, if the date range, selected on the calendar form,
doesn't capture any classes secheduled for that time then
the pull-down text box (and subform with the class
details) are blank.

Is there a way to have a message box pop-up stating
something like: "There are no classes scheduled for the
date range you have selected, please select another date
range or exit the form."

I am not sure where this would go... on which form and on
which event procedure code. Also, exactly how the code
would be written.

Any help would be greatly appreciated. Thanks!!!!!!
 
You should be able to use something like this on the
Click Event of the button on the Calendar form.

Private Sub cmdYourButtonOnClndarForm_Click()
On Error Goto HandleError

Dim dtmDateOfClass as Date

dtmDateOfClass=me.[NameOfCalendarControl].Value

If IsNull(DLookup("[PrimaryKeyOfTable]","[NameOfTable]", _
"[DateFieldInTable]=#" & dtmDateOfClass & "#") _
Then
msgbox "There are no classes for the selected " & _
date. Please select another date.",vbInformation,"No Data"
Goto ExitHere
Else
Docmd.OpenForm ["YourSecondForm'sName"]
End If

ExitHere:
Exit Sub
HandleError:
msgbox err.description & "(" & err.number & ")"
Resume ExitHere
End Sub
 
Back
Top