Using form values for criteria in a query?

kwtmd

Registered User.
Local time
Yesterday, 19:41
Joined
May 21, 2004
Messages
46
I have a form the displays several rows of a file. When I select a row, I want it to be able to pass the value of one of the fields of the selected row and use that as the criteria in a query and then open the query. How do I do this?
 
Are you using the criteria on the same field of the query every time or could it be a different field each time you want to run it?

If you use Like "*" & [Forms]![MyForm]![MyField] & "*" as your criteria all records will be returned when "MyField" is blank. This way you can have a different form control reference as criteria for each field of a query.
 
same field

Example: As I place the cursor on a given record in the Form, I want to have it change the Query value - always in the same field......



RichO said:
Are you using the criteria on the same field of the query every time or could it be a different field each time you want to run it?

If you use Like "*" & [Forms]![MyForm]![MyField] & "*" as your criteria all records will be returned when "MyField" is blank. This way you can have a different form control reference as criteria for each field of a query.
 
To make sure I understand correctly, you are saying that there could be a number of different fields within the current record on the form and with the click of a command button you want the query to use the value in the current control for its criteria?

Is this a continuous form?
 
only one field

I have a subform related to a main form (patient info). The subform scrolls through a list of problems that a patient has and is linked to the main patient info form. What I want to do is to be able to scroll through the problems and have it list the available goals for each problem. that is... each time I click on a problem, I want it to list the associated problems. I wanted to do this in a separate list box. ....... I am new Access programming but familiar with databases..... thanks for your help so far.

I tried the query you outlined, but when I placed it in the "list box" it asked for the initial parameter......
 
think I figured it out

I read that a query cannot accept a "value" but it can accept a function. I made a global function and my problem seems to be resolved... thanks
 

Users who are viewing this thread

Back
Top Bottom