Pass Subform Text Box Data to Query as Parameter

  • Thread starter Thread starter AngelT
  • Start date Start date
A

AngelT

Guest
Oh my goooooodnessss!!!!

I hope I can explain this clearly enough. Please help me!!!

I have a command button on a subform, for which "on click" I would like to have the subform "source object" updated to a form which in turn *pant, pant* runs a query that I would like the original subform text box data to pass as a parameter.

Sheeshh...*wiping the sweat from my brow*

How do I pass a value from the original forms text box to this query? Don't I just enter into the queries criteria the expression to the text box?

I just ain't get'n it right all by my little lonesome.

Thanks for your help(s). :c)
 
Why not create the query first and put as a criteria the source object? Then the button would only open the form, then the query will trigger, and look for the infomration needed in criteria.

So, Form1 holds sForm1 (the subform). Form1 has a text box (txt1) that you want as the criteria the query will be based on.

Design the query and view it in datasheet b4 you enter any criteria (good pratice). It should return all the data. Now enter in the criteria field [Form1]![txt1]. This should set the criteria to the text in the txt1 field.

So, if the name Jack is in the txt1 field, and you click the button, the query will return only the records conaining the name Jack in the field you placed the criteria on.
 
Actually the text box (from which I want to get my value from) resides within the subform.
 
All the same, the criteria can come from any source that has data entered, and if it is in the same form, all the better. Take the same train of thought and apply it to the query, or create a simple table to "catch" the data needed (1 tbl 1 field) that the query can use. Once the data is entered, the query can easily pull it from the table. I have something for printing in use now that works just like it. I have a main tbl that holds all data. The user enters data into a from that is bound to a simple table. When they click the print button, a series of quieries execute to retrive the needed data base off of the criteria in the simple tbl (what data they entered). The simple tbl is then erased to avoid duplicaiton on the next print. If your form is based off of a tbl then create a query for it to be based off of and relate the simple tbl into it. If it is based off of a query then inclued the simple tbl and set the data entry to go to the field in the simple tbl.
Ihope this isnt confusing, it is late on friday and i am worn out. But, the answer is close, let me know if this is too confusing.
 
You need the full forms criteria, open the form in design view, open the query in design view, click on the relevant criteria section, click the build button navigate to the subform control and the wizard will enter the correct criteria
Forms!MainForm!SubForm!Textbox
 

Users who are viewing this thread

Back
Top Bottom