Query Parameter

  • Thread starter Thread starter BruceRS
  • Start date Start date
B

BruceRS

I am a beginner and would like to know if there is a way
to have the parameter box show a list of choices rather
than the user being required to remember the correct
spelling for all items in the field.
 
BruceRS said:
I am a beginner and would like to know if there is a way
to have the parameter box show a list of choices rather
than the user being required to remember the correct
spelling for all items in the field.
Bruce,
Use a form.
Add a combo box to the form that shows only the correct items.
(Use the combo wizard to set this up for you.)

Add a command button to the form.
Code it's click event:
DoCmd.OpenQuery "QueryName"
DoCmd.Close acForm, Me.Name

Code the query criteria line for that field:
forms!FormName!ComboName

Only records that match the combo box selection will show in the query.
Make sure the datatype of the combo box bound column matches the
datatype of the field in the query,
 
-----Original Message-----

Bruce,
Use a form.
Add a combo box to the form that shows only the correct items.
(Use the combo wizard to set this up for you.)

Add a command button to the form.
Code it's click event:
DoCmd.OpenQuery "QueryName"
DoCmd.Close acForm, Me.Name

Code the query criteria line for that field:
forms!FormName!ComboName

Only records that match the combo box selection will show in the query.
Make sure the datatype of the combo box bound column matches the
datatype of the field in the query,
--
Fred
Please reply only to this newsgroup.
I do not respond to personal e-mail.
.
Fred,
Thank you very much for your reply, but I need a little
more help. I had no problem creating the form with the
combo box and command button. I assume it is through the
Properties of the command button that I enter
the "DoCmd. . . ." text as you have suggested. However,
when I click on the three little dots at the right side of
the OnClick line, the code seems to have a lot more in it
than I was expecting. Can you give me any more specific
help? Thanks again.
 
Thank you very much for your reply, but I need a little
more help. I had no problem creating the form with the
combo box and command button. I assume it is through the
Properties of the command button that I enter
the "DoCmd. . . ." text as you have suggested. However,
when I click on the three little dots at the right side of
the OnClick line, the code seems to have a lot more in it
than I was expecting. Can you give me any more specific
help? Thanks again.

I take it all is well up until this point...
Add a command button to the form.

You have command button. Did you use the Wizard?
If so, did you select the query to be opened?

Assuming yes to the above questions, open the form in design view.
Select the new command button.
Show the Property sheet.
Click on the Events tab.
Click on the On Click line.
The line should have [Event Procedure] on it.
Click on the button with the 3 dots.
When the code window opens you will see the code that the wizard wrote
for you to open the query.
Find the DoCmd.OpenQuery line.
Directly under it add

DoCmd.Close acForm, Me.Name

Exit the code window.
You're done.

If you did not use the wizard, then do exactly as indicated above, down
to the Click on the On Click line.

Now type [Event Procedure] on that line.
Click on the button with the 3 dots that will appear.

There will be 2 existing lines of code.
Type, between those 2 existing lines....

DoCmd.OpenQuery "TheQueryNameHere"
DoCmd.Close acForm, Me.Name

Exit the code window.
You're done.
 
-----Original Message-----
correct
items. show
in the query.
Thank you very much for your reply, but I need a little
more help. I had no problem creating the form with the
combo box and command button. I assume it is through the
Properties of the command button that I enter
the "DoCmd. . . ." text as you have suggested. However,
when I click on the three little dots at the right side of
the OnClick line, the code seems to have a lot more in it
than I was expecting. Can you give me any more specific
help? Thanks again.

I take it all is well up until this point...
Add a command button to the form.

You have command button. Did you use the Wizard?
If so, did you select the query to be opened?

Assuming yes to the above questions, open the form in design view.
Select the new command button.
Show the Property sheet.
Click on the Events tab.
Click on the On Click line.
The line should have [Event Procedure] on it.
Click on the button with the 3 dots.
When the code window opens you will see the code that the wizard wrote
for you to open the query.
Find the DoCmd.OpenQuery line.
Directly under it add

DoCmd.Close acForm, Me.Name

Exit the code window.
You're done.

If you did not use the wizard, then do exactly as indicated above, down
to the Click on the On Click line.

Now type [Event Procedure] on that line.
Click on the button with the 3 dots that will appear.

There will be 2 existing lines of code.
Type, between those 2 existing lines....

DoCmd.OpenQuery "TheQueryNameHere"
DoCmd.Close acForm, Me.Name

Exit the code window.
You're done.


--
Fred
Please reply only to this newsgroup.
I do not respond to personal e-mail.
.

Thank you for your comments. It implemented them at home
on AccessXP and all worked well, however, at work where I
use Acess97 when I click the button the query comes up
empty, yet when I run the query by its self it asks for
input.
 
Back
Top