Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking a SELECT query to a Textbox 2

Status
Not open for further replies.

dswift

Programmer
Dec 11, 2001
7
0
0
GB
I'm sure one of you techies can tell me what I am doing wrong, it is bound to be simple!

I have 2 tables Customers and Orders
Customers has a UniqueID
Orders for a particular Customer all have Orders.Customer equal to the UniqueID of the Customer table.

In the Customer form, I simply require a Textbox to show the Total cost of all orders the particular customer has.
I would like to enter
SELECT SUM(ORDERS.COST) FROM ORDERS WHERE ORDER.CUSTOMER = CUSTOMER.UNIQUEID;

When I enter this in the Control Source of the textbox, I just get #name? when I run the form.

Why?
Can you help?
Dave Swift
 
I would do an 'oncurrent' as follows:

me.MyTextBox = DSUM("COST","ORDERS","CUSTOMER = UNIQUEID")

check to be sure you do not need a runtime criteria.


rollie@bwsys.net
 
You need to use DSum in this case. Take a look at it in help, it should be easy to set up in you case...something like =DSum("[cost]","Orders","[customer] = " & me.uniqueid) assuming that your form's recordset is the customer table or a query containing that uniqueid field. Hope that helps.

Kevin
 
Thanks,

You were both right, Kevin was spot on. Code works fine now.Thanks for your help.

Dave...
 
if you are helped by these, click a star for the helpers

Rollie E
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top