If then Else statement to pull a query

V

VJ

Hi,

I have a database of vendors I am putitng together, I am doing a search on
it and I want to select a certain query based on a category in the form. I
am pulling too many fields to just use one query so I want to split it up to
run the hotel query if that category is selected or restaurants. How do I do
this in VBA?
This is how I started out
If [Forms]![Search2].[Category 1]= “1 or 2†then stDocName= “Hotel Queryâ€

I have about 14 categories but outside of Hotel and Restaurant i can call
them to one query. Please help. Thanks in advance.
 
R

Ryan

Why not have a form that only has a category dropdown on it that lists all 14
of your categories. Then you could have a form for each category that
displays the information you would want to see. You would need this code in
the after update event of the category dropdown.

Private Sub CategoryDropdownName_AfterUpdate()
Dim stDocName as String
stDocName = (Me.CategoryDropdownName)
DoCmd.OpenForm stDocName
DoCmd.Close acForm, "CategorySelectionFormName"
Exit Sub


Private Sub QuickSearchTroubleTicket_AfterUpdate()

End Sub
 
V

VJ

I am not sure if that will work, I will try it but here is the deal with this
database. The people who will search through it need to pull information
such as a hotel in a particular state or a restaurant in a particular city or
a restaurant in a city with a private room and X amount of capacity. I
started out with a query but there are so many criteria its not pulling all
of them properly. I already have a form for them to input hotels and
restaurants because that is the largest aspect of this database. Does that
make sense?
Thanks
Ryan said:
Why not have a form that only has a category dropdown on it that lists all 14
of your categories. Then you could have a form for each category that
displays the information you would want to see. You would need this code in
the after update event of the category dropdown.

Private Sub CategoryDropdownName_AfterUpdate()
Dim stDocName as String
stDocName = (Me.CategoryDropdownName)
DoCmd.OpenForm stDocName
DoCmd.Close acForm, "CategorySelectionFormName"
Exit Sub


Private Sub QuickSearchTroubleTicket_AfterUpdate()

End Sub
--
Please remember to mark this post as answered if this solves your problem.


VJ said:
Hi,

I have a database of vendors I am putitng together, I am doing a search on
it and I want to select a certain query based on a category in the form. I
am pulling too many fields to just use one query so I want to split it up to
run the hotel query if that category is selected or restaurants. How do I do
this in VBA?
This is how I started out
If [Forms]![Search2].[Category 1]= “1 or 2†then stDocName= “Hotel Queryâ€

I have about 14 categories but outside of Hotel and Restaurant i can call
them to one query. Please help. Thanks in advance.
 

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