Query Criteria

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can anyone advise if it's possible and how to get a query to use criteria
entered in a text box in a form. I have a command buttion that prints a
report on my form. The report uses a query that asks for claim number to
print data. I would like the claim number entered in the text box on the form
to be sent to the query.

Any help is greatly appreciated.

Thanks,
Sherry N.
 
Sherry said:
Can anyone advise if it's possible and how to get a query to use criteria
entered in a text box in a form. I have a command buttion that prints a
report on my form. The report uses a query that asks for claim number to
print data. I would like the claim number entered in the text box on the form
to be sent to the query.


THe query criteria would most likely be something like:

Forms!theform.thetextbox

But, you can accomplish this without messing around with the
query. Change the OpenReport line of code in the command
button's event procedure to use its WhereCondition argument.
If the claim number field in the table is a numeric type:
DoCmd.OpenReport stDoc, , , "claimnum= " & thetextbox

If Claim number is a text field:
DoCmd.OpenReport stDoc, , , "claimnum= """ & thetextbox &
""""
 
the query shoul look like that

select * from MyTable whare claimNumber = Forms![FormName]![FieldName]
 
Thank you! Thank you! Thank you!

Marshall Barton said:
THe query criteria would most likely be something like:

Forms!theform.thetextbox

But, you can accomplish this without messing around with the
query. Change the OpenReport line of code in the command
button's event procedure to use its WhereCondition argument.
If the claim number field in the table is a numeric type:
DoCmd.OpenReport stDoc, , , "claimnum= " & thetextbox

If Claim number is a text field:
DoCmd.OpenReport stDoc, , , "claimnum= """ & thetextbox &
""""
 
Thank you! Thank you! Thank you!

Ofer said:
the query shoul look like that

select * from MyTable whare claimNumber = Forms![FormName]![FieldName]


Sherry N. said:
Can anyone advise if it's possible and how to get a query to use criteria
entered in a text box in a form. I have a command buttion that prints a
report on my form. The report uses a query that asks for claim number to
print data. I would like the claim number entered in the text box on the form
to be sent to the query.

Any help is greatly appreciated.

Thanks,
Sherry N.
 
Back
Top