By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 884 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

WhereClause problem using SQL Server

P: 1
I just upsized my Access mdb to a SQL server backend. Now I'm working on the access ADP project to make it work right, so here is the problem.

I have a tabel of Customers open with their orders listed in a subform. I use a command button to open an order in a detailed view. the command is below
******************
Private Sub OrdersNew_Click()
On Error GoTo Err_OrdersNew_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Orders"

stLinkCriteria = "Orders.[CustomerID]=" & Me![CustomerID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_OrdersNew_Click:
Exit Sub

Err_OrdersNew_Click:
MsgBox Err.Description
Resume Exit_OrdersNew_Click

End Sub
********************
The Orders Form has the following SQL

SELECT dbo.Orders.*, dbo.Customers.Pricing
FROM dbo.Orders INNER JOIN
dbo.Customers ON dbo.Orders.CustomerID = dbo.Customers.CustomerID
*************************

The Problem:
I click on the command button and get the following error:
'The columb prefix 'Orders' does not match with a table name or alias name used in query.'

?????? Any ideas???????
Oct 20 '06 #1
Share this Question
Share on Google+
1 Reply


MMcCarthy
Expert Mod 10K+
P: 14,534
Try this code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub OrdersNew_Click()
  3. On Error GoTo Err_OrdersNew_Click
  4.  
  5. Dim stDocName As String
  6. Dim stLinkCriteria As String
  7.  
  8. stDocName = "Orders"
  9.  
  10. stLinkCriteria = "[CustomerID]=" & Me.[CustomerID]
  11. DoCmd.OpenForm stDocName, , , stLinkCriteria
  12.  
  13. Exit_OrdersNew_Click:
  14. Exit Sub
  15.  
  16. Err_OrdersNew_Click:
  17. MsgBox Err.Description
  18. Resume Exit_OrdersNew_Click
  19.  
  20. End Sub
  21.  
  22.  
Oct 20 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.