Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Help with Access SQL Statement

Posted on 2009-05-07
3
Medium Priority
?
234 Views
Last Modified: 2012-05-06
I have an event procedure within an Access application that has the following query:

DoCmd.RunSQL "Delete * FROM [Payments] WHERE [Payments].OrderID = [Orders].OrderID AND [Orders].CustomerID = " & CustomerNumber & ";"

When it gets to this statement, it keeps prompting me for "[Orders].OrderID".  Orders is a table in the database, and OrderID is the Primary key in that table.

for the life of me I cannot see what is wrong with this statement.

Can someone please help.

Thanks...Tom
0
Comment
Question by:tpigielski
3 Comments
 
LVL 13

Expert Comment

by:usachrisk1983
ID: 24332752
But it doesn't know what [orders].orderid is.  I suspect that it's a field on your form somewhere?  If so, use the control name instead.  You'll need to do the same for the other items in your WHERE clause.
0
 
LVL 25

Accepted Solution

by:
lwadwell earned 1000 total points
ID: 24332789
Hi tpigielski,

Is this what you want?

DoCmd.RunSQL "Delete * FROM [Payments] WHERE [Payments].OrderID IN (SELECT [Orders].OrderID FROM [Orders] WHERE [Orders].CustomerID = " & CustomerNumber & ");"


lwadwell
0
 
LVL 6

Expert Comment

by:BALMUKUND KESHAV
ID: 24333137
Do hope there must be a textbox/combo box having data of orders.orderid , customerid, put that control instead of orders.orderid, if your textbox/combo box havign data of orders,orderid is txtorderid and customerid is txtcustomerid, then use the sql qry like this :

DoCmd.RunSQL "Delete * FROM [Payments] WHERE [Payments].OrderID = txtorderid AND [Payments].customerid = " & CustomerNumber & ";"

Bm keshav
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question