Including text from a form in a query

Henley12

Troy University Fan
Local time
Yesterday, 23:51
Joined
Oct 10, 2007
Messages
222
I know this is probably an easy solution, but my brain is not functioning properly at the moment. I have a query that lists the usual from some tables, but I want to include a field from the current form the query is run from. What is the method to do that? For example, I have a Work Order form that combines all labor comments from another table for one work order into a single field on my Work Order form. It doesn't store this information anywhere, just displays the concatenated data on the form for the current record. Is there a way to make that data show up in my query?
 
In the design grid in a new column:

Whatever: Forms!FormName.ControlName
 
When I put that into the design grid, it prompts me for the fieldname. The name of my form is frmWorkOrders and the field is Comments. I put into the grid as such:

Comments:Forms!frmWorkOrders.Comments

Then the box "Enter parameter value" pops up with Forms!frmWorkOrders.Comments.
 
When I put that into the design grid, it prompts me for the fieldname. The name of my form is frmWorkOrders and the field is Comments. I put into the grid as such:

Comments:Forms!frmWorkOrders.Comments

Then the box "Enter parameter value" pops up with Forms!frmWorkOrders.Comments.

Is Forms!frmWorkOrders open at the time you are executing the query? If it is not, Ms Access will not be able to resolve the reference to Forms!frmWorkOrders.Comments, and will need to ask you for your help.
 
Yes, the form is open at the same time. What I am trying to accomplish is actually print out the current work order. I have a print button on the form which runs the report based on this query. In testing, I am just opening the form and running the query directly.
 
It's not on a subform, is it?
 
Then I think either the form or textbox name is misspelled. If not, can you post the db?
 
No misspelling........however, I just found the problem. The field was locked.
 
Sorry to cause the headache. I should have realized that earlier. I knew the field was locked because I don't want anybody to be able to edit it. I did not know it would affect a query, however.
 
Truth be told, I didn't know that would affect the query either. Glad you sorted it out.
 

Users who are viewing this thread

Back
Top Bottom