Parameter Query question

G

Guest

I am trying to run a query based on a value in a control (SSN). I would
like the code to be attached to a command button so when triggered it will
use the SSN already shown on the form to execute the query.

In other words, I am trying to avoid the parameter query where the user
would have to enter the SSN to execute the query.
 
T

Todd Shillam

You build a query and 'bound' the SSN field to the form's control.

1. Open the form with the chosen control.
2. Open the chosen query in design mode.
3. In the SSN field's 'Criteria' block in the bottom of the window, right-click and select the 'Build..' option--this will open the Expression Builder window.
4. On the left side of the Expression Builder, click 'Forms' to expand.
5. Expand 'Loaded Forms' and click the form with the control.
6. In the middle pane of the Expression Builder window, click the control's name.
7. In the right pane of the Expression Builder window, double, left-click <value> option.
8. Click the {OK} button on the Expression Builder window.
9. Save and close your query.

Your query's SSN is now bound to the form's SSN control.

Best regards,

Todd
I am trying to run a query based on a value in a control (SSN). I would
like the code to be attached to a command button so when triggered it will
use the SSN already shown on the form to execute the query.

In other words, I am trying to avoid the parameter query where the user
would have to enter the SSN to execute the query.
 
L

Larry Daugherty

Hi,

Depending on what you're doing there could be more than one way to skin the
cat.

If you have the SSNs on tap and find the one you want in a combobox then you
could use the AfterUpdate event of that combobox to run your query and pass
in something like:

Where SSN=me!mySSNControl

If you intend to load your form with data from the record with that SSN you
might want to replace the existing text box with a combobox. Start the
combobox from scratch to get the wizard to do the work.

If you really do want to type the SSN into a textbox and then hit a command
button to run a named query then in the query's criteria line for the SSN
field put

like forms!MyForm!mySSNControl.

HTH
 
Top