How to run a report based on user's options

dealwi8me

Registered User.
Local time
Today, 04:05
Joined
Jan 5, 2005
Messages
187
Hello,

I need help with something (i attached a database).
I need to run a report based on user's options so i created a form. There are two comboboxes and 2 checkboxes on the form. If the checkbox is checked i want to consider the choice of the user on the particular combobox. If no, to ignore that column.
The second problem is when the user choose "no choice" i want the query to run for all choices without filtering the combobox.

Any suggestions?

Thank you in advance.
 

Attachments

I would suggest creating a module with a Criteria, I'm assuming that this is an either/or situation and having set the Checkbox the forms ensures that the relevant combobox has an entry and these are string fields?

Private Function Your_Criteria

With CodeContextObject

if .[CheckBox1] = True then
Your_Criteria = "[YourField] = & '" [ComboBox1] & "'"
Elseif .[CheckBox2] = True then
Your_Criteria = "[YourField] = & '" [Combobox2] & "'"
End if
End With
End Function

Function OpenReport

With CodeContextObject

if .[CheckBox1] = True or .[Checkbox2] = True
DoCmd.OpenReport "YourReport", A_PREVIEW, , Your_Criteria
else
DoCmd.OpenReport "YourReport", A_PREVIEW
End if
End With
End Function
 

Users who are viewing this thread

Back
Top Bottom