How to connect a ComboBox to a Query?

R

RoMi

I am on the edge!

On the main form frmView there are a combo box cboDept and a sub form
sfrmData which is used to show a query qryDocs in a Datasheet view. An user
may use a combo box to choose a parameter to filter the data in the qryDocs.
In this case the criteria for data selection is the value of the field
SifDept (which may have the data like 1.1., 2.5., 9.5., etc.).

It would be useful to have an option group on a form frmView, too. In that
case valid documents could be separated from the other ones. (The field
Valid has a value Yes or No).

The main task is that the frmView is a Single form, it must keep some
control objects while a query on a subform has to be shown in a datasheet
view.

Thanks for your help
 
T

Tim Ferguson

RoMi said:
On the main form frmView there are a combo box cboDept and a sub form
sfrmData which is used to show a query qryDocs in a Datasheet view. An
user may use a combo box to choose a parameter to filter the data in
the qryDocs.

You should have a parameter in the query that points to the control on the
form:

... WHERE SifDept = Forms!frmView!cboDept.Value

It would be useful to have an option group on a form frmView, too. In
that case valid documents could be separated from the other ones. (The
field Valid has a value Yes or No).

You can use an IIf function to return TRUE for all cases, or only ones
where the field itself is TRUE.

... AND IIf(Forms!frmView!chkValidOnly.Value=True,
Valid=TRUE,
TRUE)

Strictly speaking, you could contract this using an OR, but this version is
more readable.

HTH

Tim F
 

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