dbTalk Databases Forums  

Assigning value from query to a text box

comp.database.ms-access comp.database.ms-access


Discuss Assigning value from query to a text box in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
 
Posts: n/a

Default Assigning value from query to a text box - 04-20-2006 , 09:51 PM






Hi everyone,

I have a form with a combo box on it. When you select a value (a PO#) from
the combo box, the bound field is the indexID of the selected PO. On the
same form, I have a text box that I'd like to feed from a query I've built.
The query does some math and comes up with a number (qty allocated) for the
selected PO. There are two tricky parts here. That query I've built needs
to filter on the indexID that gets selected from the combo box on the form.
Next, on the text box in the form, I've assigned the control source to be
the query's value. Since there is only one field in the result of the
query, there isn't much to choose from. When I launch the form, I get
#Name? in the text box. Very annoying since I don't know where else to
look. Here are the 3 components:

Combo box on the form (cmboOEPOList):
Bound Column is 1 (the IndexID)
SELECT tOrders.IndexID, tOrders.PONum, tOrders.OurItemNum1, tOrders.POQty1,
tOrders.OurItemNum2, tOrders.POQty2, tOrders.OurItemNum3, tOrders.POQty3,
tOrders.OurItemNum4, tOrders.POQty4, tRefVendors.Vendor FROM tRefVendors
INNER JOIN tOrders ON tRefVendors.VendorID=tOrders.VendorID WHERE
((([tOrders.PONum]) Like "*oe*")) ORDER BY tOrders.PONum;

Query to get my qty allocated:
SELECT Sum(tPartsSent.Item1Allocated) AS TotalAllocated
FROM tOrders INNER JOIN tPartsSent ON tOrders.IndexID = tPartsSent.IndexID
GROUP BY tOrders.IndexID, tOrders.IndexID, tOrders.POQty1
HAVING (((tOrders.IndexID)=[Forms]![FormPartsSent]![cmboOEPOList]));

txt65
txtBox on Form where I'm trying to display the value of the qtyallocated
from the query where it filters on the indexID of the combo box
Control Source: =qItem1TotalAllocated!TotalAllocated

Does anyone know why in the world this isn't connecting and instead, I get
#Name? in the textbox txt65? I'd really apreciate any help I can get here.
This newsgroup is typically awesome in terms of getting me out of these
tricky binds. Thanks!



Reply With Quote
  #2  
Old   
Ira Solomon
 
Posts: n/a

Default Re: Assigning value from query to a text box - 04-22-2006 , 03:55 PM






Hi:

A text box cannot execute a query unless you use an event.
The easiest way to do this is to use the onupdate or onchange event in
the combo.
In that event use a the dfind function on the query, or perhaps you
could use the dsum and not need the full query.
Assign result to txt65:
me.txt65 = DSum(.....).
You will probably need the same code in the OnOpen for the form or
else it won't populate for the default key in the combo box.

I hope this makes sense.

Good luck
Ira Solomon

On Thu, 20 Apr 2006 22:51:04 -0400, <MX1> wrote:

Quote:
Hi everyone,

I have a form with a combo box on it. When you select a value (a PO#) from
the combo box, the bound field is the indexID of the selected PO. On the
same form, I have a text box that I'd like to feed from a query I've built.
The query does some math and comes up with a number (qty allocated) for the
selected PO. There are two tricky parts here. That query I've built needs
to filter on the indexID that gets selected from the combo box on the form.
Next, on the text box in the form, I've assigned the control source to be
the query's value. Since there is only one field in the result of the
query, there isn't much to choose from. When I launch the form, I get
#Name? in the text box. Very annoying since I don't know where else to
look. Here are the 3 components:

Combo box on the form (cmboOEPOList):
Bound Column is 1 (the IndexID)
SELECT tOrders.IndexID, tOrders.PONum, tOrders.OurItemNum1, tOrders.POQty1,
tOrders.OurItemNum2, tOrders.POQty2, tOrders.OurItemNum3, tOrders.POQty3,
tOrders.OurItemNum4, tOrders.POQty4, tRefVendors.Vendor FROM tRefVendors
INNER JOIN tOrders ON tRefVendors.VendorID=tOrders.VendorID WHERE
((([tOrders.PONum]) Like "*oe*")) ORDER BY tOrders.PONum;

Query to get my qty allocated:
SELECT Sum(tPartsSent.Item1Allocated) AS TotalAllocated
FROM tOrders INNER JOIN tPartsSent ON tOrders.IndexID = tPartsSent.IndexID
GROUP BY tOrders.IndexID, tOrders.IndexID, tOrders.POQty1
HAVING (((tOrders.IndexID)=[Forms]![FormPartsSent]![cmboOEPOList]));

txt65
txtBox on Form where I'm trying to display the value of the qtyallocated
from the query where it filters on the indexID of the combo box
Control Source: =qItem1TotalAllocated!TotalAllocated

Does anyone know why in the world this isn't connecting and instead, I get
#Name? in the textbox txt65? I'd really apreciate any help I can get here.
This newsgroup is typically awesome in terms of getting me out of these
tricky binds. Thanks!


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.