WhereClause problem using SQL Server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kiroaepi
    New Member
    • Oct 2006
    • 1

    #1

    WhereClause problem using SQL Server

    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_C lick

    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_C lick:
    MsgBox Err.Description
    Resume Exit_OrdersNew_ Click

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

    SELECT dbo.Orders.*, dbo.Customers.P ricing
    FROM dbo.Orders INNER JOIN
    dbo.Customers ON dbo.Orders.Cust omerID = dbo.Customers.C ustomerID
    *************** **********

    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???????
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    Try this code:

    Code:
     
    Private Sub OrdersNew_Click()
    On Error GoTo Err_OrdersNew_Click
     
    Dim stDocName As String
    Dim stLinkCriteria As String
     
    stDocName = "Orders"
     
    stLinkCriteria = "[CustomerID]=" & Me.[CustomerID]
    DoCmd.OpenForm stDocName, , , stLinkCriteria
     
    Exit_OrdersNew_Click:
    Exit Sub
     
    Err_OrdersNew_Click:
    MsgBox Err.Description
    Resume Exit_OrdersNew_Click
     
    End Sub

    Comment

    Working...