I'm sure the answer to the question above is yes. I just can't seem to make it work.
I've got a form titled Line-Item PO Search. On this form are a couple of fields in which the user can input the following information: CustomerID, PO#, Start Date, and End Date.
These fields serve as the parameters of a query called Line-Item PO Query.
Line-Item PO Query looks at my Order Details table and returns results for any order from CustomerID x that has PO# y, that was made between Start Date and End Date. It gives me the SKU of the product ordered, the ProductName, and the PricePerUnit (among a few other fields)
Line-Item PO Query doesn't give me the data I need, however. I need the total expenditure made under the PO# in question in my time window.
To get that, I created a 2nd query, Line-Item PO Query Totals, which uses Line-Item PO Query as its source. I take the two fields I need, PricePerUnit and QuantityShipped and use the SUM function. Viola, the result I need, under the headers SumOfPricePerUnit and SumOfQuantityShipped.
The idea is that my user can input his or her criteria on the Line-Item PO Search form, hit a button which has DoCmd.OpenQuery "Line-Item PO Query Totals" as its OnClick event. So far so good. All works as intended.
What I want is for two textboxes on the Line-Item PO Search form to display the results of the Line-Item PO Query Totals query. And I'm failing miserably. I've set the record source of the form to be the Line-Item PO Query Totals query, which I think is right. I initially set the control source of my results textbox to PricePerUnit, but that got me a ?Name error, so I set it to SumOfPricePerUnit. That cleared the ?Name error, but the textbox isn't picking up the query result when I hit the Search button to run the query; it's just blank.
I read somewhere that I can't just use the name of the query field in this kind of situation, and that the recommended way to go about it was to use a DLookUp as the control source for my textbox, so I tried
=DLookup("[SumOfPricePerUnit]", "Line-Item PO Query Totals") as the control source. It workedthe very first time, but not any subsequent tries. Obviously, I'm missing something, but I don't know what it is. Do I need to reset the value of the result textbox before I can query again? I'm not sure how I go about that.
~Gene
I've got a form titled Line-Item PO Search. On this form are a couple of fields in which the user can input the following information: CustomerID, PO#, Start Date, and End Date.
These fields serve as the parameters of a query called Line-Item PO Query.
Line-Item PO Query looks at my Order Details table and returns results for any order from CustomerID x that has PO# y, that was made between Start Date and End Date. It gives me the SKU of the product ordered, the ProductName, and the PricePerUnit (among a few other fields)
Line-Item PO Query doesn't give me the data I need, however. I need the total expenditure made under the PO# in question in my time window.
To get that, I created a 2nd query, Line-Item PO Query Totals, which uses Line-Item PO Query as its source. I take the two fields I need, PricePerUnit and QuantityShipped and use the SUM function. Viola, the result I need, under the headers SumOfPricePerUnit and SumOfQuantityShipped.
The idea is that my user can input his or her criteria on the Line-Item PO Search form, hit a button which has DoCmd.OpenQuery "Line-Item PO Query Totals" as its OnClick event. So far so good. All works as intended.
What I want is for two textboxes on the Line-Item PO Search form to display the results of the Line-Item PO Query Totals query. And I'm failing miserably. I've set the record source of the form to be the Line-Item PO Query Totals query, which I think is right. I initially set the control source of my results textbox to PricePerUnit, but that got me a ?Name error, so I set it to SumOfPricePerUnit. That cleared the ?Name error, but the textbox isn't picking up the query result when I hit the Search button to run the query; it's just blank.
I read somewhere that I can't just use the name of the query field in this kind of situation, and that the recommended way to go about it was to use a DLookUp as the control source for my textbox, so I tried
=DLookup("[SumOfPricePerUnit]", "Line-Item PO Query Totals") as the control source. It workedthe very first time, but not any subsequent tries. Obviously, I'm missing something, but I don't know what it is. Do I need to reset the value of the result textbox before I can query again? I'm not sure how I go about that.
~Gene