Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Help with Access SQL Statement

Posted on 2009-05-07
3
Medium Priority
?
233 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

722 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