form... msgbox???

M

Mark

Hi,

I have two forms (ClassCalendar and ClassRegistration).
From the switchboard, the user will go to the
ClassCalendar form, select a date range, and click a
command button that will open up the ClassRegistration
form. The ClassRegistration form has a pull-down text box
that lists all the classes that are available for the
selected date range picked from the ClassCalendar form.
The pull-down text box is populated from a query that
lists the classes' id number. The form also has a subform
that lists all of the classes' details, such as title,
location, etc.

All works fine, but I would like to have a message box
come up if there are no classes available for the date
range the user has selected. How do I go about doing this?

I'm not sure where I would use an event procedure in one
of the forms properties and how the code would be
written. The query is based on criteria of "ClassDate":

Between [Forms]![formClassCalendar]![TextBeginningDate]
And [Forms]![formClassCalendar]![TextEndDate] And >=Date()

Thanks for helping me out!!!!
 
B

Bogdan Zamfir

Hi,

You should add some code to check if the query returns any records in the
Click event fo the button who open the ClassRegistration form

If there are records, continue and open ClassRegistration, otherwise show
the messagebox.
Something like this:

sub Button_click()
dim rs as recordset
set rs = currentdb.openrecordset("select count(*) as cnt from <yourtable>
where <your condition as in ClassRegistration>")
if rs!cnt =0 then
MsgBox "There are no classes available for selected date range!"
else
'.... your existing code to open ClassRegistration
docmd.OpenForm "frmClassRegistration", ....
endif
end sub

HTH,
Bogdan
_________________________
Freelance programmer
 
M

Mark

Hi Bogdan,

Thanks for the help. I will give it a try.

Have a good one over there!!!!!!!

-----Original Message-----
Hi,

You should add some code to check if the query returns any records in the
Click event fo the button who open the ClassRegistration form

If there are records, continue and open
ClassRegistration, otherwise show
the messagebox.
Something like this:

sub Button_click()
dim rs as recordset
set rs = currentdb.openrecordset("select count(*) as cnt
from said:
where <your condition as in ClassRegistration>")
if rs!cnt =0 then
MsgBox "There are no classes available for selected date range!"
else
'.... your existing code to open ClassRegistration
docmd.OpenForm "frmClassRegistration", ....
endif
end sub

HTH,
Bogdan
_________________________
Freelance programmer








Hi,

I have two forms (ClassCalendar and ClassRegistration).
From the switchboard, the user will go to the
ClassCalendar form, select a date range, and click a
command button that will open up the ClassRegistration
form. The ClassRegistration form has a pull-down text box
that lists all the classes that are available for the
selected date range picked from the ClassCalendar form.
The pull-down text box is populated from a query that
lists the classes' id number. The form also has a subform
that lists all of the classes' details, such as title,
location, etc.

All works fine, but I would like to have a message box
come up if there are no classes available for the date
range the user has selected. How do I go about doing this?

I'm not sure where I would use an event procedure in one
of the forms properties and how the code would be
written. The query is based on criteria of "ClassDate":

Between [Forms]![formClassCalendar]![TextBeginningDate]
And [Forms]![formClassCalendar]![TextEndDate] And >=Date ()

Thanks for helping me out!!!!


.
 

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

Similar Threads


Top