Open a From based on Criteria

W

weircolin

Hi There

I would like to be able to open a form based on a selection from a
Combo Box. I know I can do this using If Then Else statements.
However, is it possible to just have one from and be ale to have it
that it opens based on certain values within the records.

I'll do it in a non access language to see if this explains it better

If cbofromcriteria.Value = 1 Then Open Form where all records =
cbocriteria = 1

I would like to do it this way rather than creating lots of different
foms for each criteria.

Don't know if that makes sense?

Cheers

Colin
 
F

fredg

Hi There

I would like to be able to open a form based on a selection from a
Combo Box. I know I can do this using If Then Else statements.
However, is it possible to just have one from and be ale to have it
that it opens based on certain values within the records.

I'll do it in a non access language to see if this explains it better

If cbofromcriteria.Value = 1 Then Open Form where all records =
cbocriteria = 1

I would like to do it this way rather than creating lots of different
foms for each criteria.

Don't know if that makes sense?

Cheers

Colin

What's the name of the field in the table that is used as the criteria
field?
What's the name of the combo box "cbofromcriteria" or "cbocriteria"?

DoCmd.OpenForm "FormName", , ,"[SomeFieldInTable] = " & Me.ComboName
 
W

weircolin

Hi there

Thanks for replying.

I haven't creaed the combobox for selecting the criteria yet. The
combo box on the form is called cbouserorcarer.

Thanks

Colin
 
F

fredg

Hi there

Thanks for replying.

I haven't creaed the combobox for selecting the criteria yet. The
combo box on the form is called cbouserorcarer.

Thanks

Colin

Please include the relevant portion of any previous message in your
replies (as I have done with my previous reply and with this one).
This way, a reader doesn't have to search out the previous message.
You may remember all of the previous messages in regards to your
question, but I doubt that others will.

Substitute your actual combo field name for ComboName and substitute
the actual name of the field used as the criteria field in the table
for [SomeFieldInTable].
The code I gave you assumes the datatype of the[SomeFieldInTable] is
Number, and the bound column of ComboName is also a number value.

Different datatypes require a different syntax.
Look up, in VBA help,
Where Clause
as well as
Restrict data to a subset of records
for more information.
 

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