using form variables to find a record

E

Eugene Wohlfarth

I have a table with 25 fields. What I would like to do is enter variable
information to search the table to find a record. If I were coding it might
look like this:

if ind_oon_ded = 2000 and fam_oon_ded = 5000.....Then display PVC_code

I am entering the variables via a form with combo boxes.

I am also attempting to do this with a report, but that's a later question.

Can anyone shed some light on this dimwhit?

Thanks in advance ,

Eugene
 
J

Jeff Boyce

Eugene

Create a new query.

Add the table. Add the fields.

In the selection criterion under [ind_oon_ded], put 2000. Put the other
criterion under it's field.

Run the query. You should get only those records with those criteria.

Now, since you are using a form, replace the "2000" with something like
(untested):

Forms!YourFormName!cboYourFirstComboboxName

and the "5000" with (also untested):

Forms!YourFormName!cboYourSecondComboboxName

Go back to YourFormName in design view, add a command button that runs your
query.

NOTE: for this approach to work, you need:

1. The form to be open
2. The comboboxes to have values in
3. The comboboxes to be set up so that the value (i.e., the first
column) is the value that you want to use in the query

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or psuedocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
E

Eugene Wohlfarth

Jeff,

Thanks for the tip, I'll give it a try. I do have an after thought, is there
anything specific I need to do to handle a "null" value?

Thanks,

Eugene

Jeff Boyce said:
Eugene

Create a new query.

Add the table. Add the fields.

In the selection criterion under [ind_oon_ded], put 2000. Put the other
criterion under it's field.

Run the query. You should get only those records with those criteria.

Now, since you are using a form, replace the "2000" with something like
(untested):

Forms!YourFormName!cboYourFirstComboboxName

and the "5000" with (also untested):

Forms!YourFormName!cboYourSecondComboboxName

Go back to YourFormName in design view, add a command button that runs your
query.

NOTE: for this approach to work, you need:

1. The form to be open
2. The comboboxes to have values in
3. The comboboxes to be set up so that the value (i.e., the first
column) is the value that you want to use in the query

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or psuedocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

Eugene Wohlfarth said:
I have a table with 25 fields. What I would like to do is enter variable
information to search the table to find a record. If I were coding it
might
look like this:

if ind_oon_ded = 2000 and fam_oon_ded = 5000.....Then display PVC_code

I am entering the variables via a form with combo boxes.

I am also attempting to do this with a report, but that's a later
question.

Can anyone shed some light on this dimwhit?

Thanks in advance ,

Eugene


.
 
J

Jeff Boyce

As a criterion in a query, check for "Null" (Access converts this to "Is
Null").

However!!! to the human eye, a null, a zero-length string, a blank, and 27
spaces all look the same. Make sure your query criteria handle these.

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or psuedocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.


Eugene Wohlfarth said:
Jeff,

Thanks for the tip, I'll give it a try. I do have an after thought, is
there
anything specific I need to do to handle a "null" value?

Thanks,

Eugene

Jeff Boyce said:
Eugene

Create a new query.

Add the table. Add the fields.

In the selection criterion under [ind_oon_ded], put 2000. Put the other
criterion under it's field.

Run the query. You should get only those records with those criteria.

Now, since you are using a form, replace the "2000" with something like
(untested):

Forms!YourFormName!cboYourFirstComboboxName

and the "5000" with (also untested):

Forms!YourFormName!cboYourSecondComboboxName

Go back to YourFormName in design view, add a command button that runs
your
query.

NOTE: for this approach to work, you need:

1. The form to be open
2. The comboboxes to have values in
3. The comboboxes to be set up so that the value (i.e., the first
column) is the value that you want to use in the query

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or psuedocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

Eugene Wohlfarth said:
I have a table with 25 fields. What I would like to do is enter variable
information to search the table to find a record. If I were coding it
might
look like this:

if ind_oon_ded = 2000 and fam_oon_ded = 5000.....Then display
PVC_code

I am entering the variables via a form with combo boxes.

I am also attempting to do this with a report, but that's a later
question.

Can anyone shed some light on this dimwhit?

Thanks in advance ,

Eugene


.
 

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