Can I auto populate criteria for a query based on a form?

G

Gretchen

I have a form with command buttons. The command buttons run update queries.
I want to update a table with criteria from my form (LabIDNumber). Is there
anyway for the query to pull the LabID from the form that is currently active?
Thanks for help.
 
S

Sprinks

Gretchen,

Sure. Put a reference to the form control in the criteria row of the query:

= Forms!YourForm!YourControl

Sprinks
 
G

Gretchen

Humm...this did not work. When I put this on the criteria first of all it
automatically reformats the criteria and I loose the "=" sign. When I hit
the control button it runs the query but asks for parameters for "LabID" -
the field I"m trying to get the query to know from my form.

Thanks in advance for your help.
 
K

kingston via AccessMonster.com

Use something like the following in the update query to refer to the value in
the form:

[Forms]![FormName]![LabIDControlName]

IOW, modify the update query where the Update To: section contains the above
expression where appropriate.
 
K

kingston via AccessMonster.com

That was supposed to be in the Criteria section rather than the Update To:
section.
Use something like the following in the update query to refer to the value in
the form:

[Forms]![FormName]![LabIDControlName]

IOW, modify the update query where the Update To: section contains the above
expression where appropriate.
I have a form with command buttons. The command buttons run update queries.
I want to update a table with criteria from my form (LabIDNumber). Is there
anyway for the query to pull the LabID from the form that is currently active?
Thanks for help.
 
J

John Vinson

I have a form with command buttons. The command buttons run update queries.
I want to update a table with criteria from my form (LabIDNumber). Is there
anyway for the query to pull the LabID from the form that is currently active?
Thanks for help.

Sure; use a criterion like

[Forms]![NameOfYourForm]![NameOfSomeControl]

John W. Vinson[MVP]
 
S

Sprinks

Gretchen,

I've tried to duplicate your results but have been unable to. Perhaps we're
using a different version. In any case, try:

- Verifying that the column in which you're entering the criteria is the
field to which the referenced control is bound
- Add delimiter brackets around each specifier, in case your form or control
names have spaces:

= Forms![Your Form]![Your Control]

If this doesn't work, please post:
- the name of the query field in which you're trying to add the criteria
- the name of the form
- the name and Control Source of the form control that has the matching data
- the full SQL of the query

Sprinks
 
J

John Vinson

Humm...this did not work. When I put this on the criteria first of all it
automatically reformats the criteria and I loose the "=" sign. When I hit
the control button it runs the query but asks for parameters for "LabID" -
the field I"m trying to get the query to know from my form.

Thanks in advance for your help.

Please post the SQL view of your Query.

John W. Vinson[MVP]
 
Top