This Record Already Exist?

Maldrid

Registered User.
Local time
Today, 04:02
Joined
Jul 24, 2003
Messages
20
This Record Already Exist? [Resolved]

Why am I getting a "This Record Already Exist" error when I am just doing a query?

Code:
'This query works prefectly and I get the results I want.
sSQLQuery = "SELECT * FROM Prices WHERE KitchenID = '" & txtKitchenID _
            & "' AND [Customer ID] = '" & txtCustomer _
            & "' AND [Bill Code] = '" & cmbBillCode & "' ORDER BY [Effective Date]"
                
        If rsPrice.State = adStateOpen Then
            rsPrice.Close
        End If
                
        
        rsPrice.CursorType = adOpenStatic
        rsPrice.LockType = adLockReadOnly
        rsPrice.Source = sSQLQuery
        rsPrice.Open
        
        'Then I go and do this query and it blows up when it gets to
        'rs.open. 
        sSQLQuery = "SELECT DISTINCT [Price Type] FROM Prices WHERE KitchenID = '" & txtKitchenID _
            & "' AND [Customer ID] = '" & txtCustomer _
            & "' AND [Bill Code] = '" & cmbBillCode _
            & "' AND [Price Type] <> '' ORDER BY [Effective Date]"

        If rs.State = adStateOpen Then
            rs.Close
        End If
        
        rs.CursorType = adOpenStatic
        rs.LockType = adLockReadOnly
        rs.Source = sSQLQuery
        rs.Open
 
        'I tried doing this and it still errors.
        sSQLQuery = "SELECT DISTINCT [Price Type] FROM Prices WHERE KitchenID = '" & txtKitchenID _
            & "' AND [Customer ID] = '" & txtCustomer _
            & "' AND [Bill Code] = '" & cmbBillCode "'"

       'I also tried this and it errors as well 
       sSQLQuery = "SELECT DISTINCT [Price Type] FROM Prices WHERE KitchenID = '" & txtKitchenID _
            & "' AND [Customer ID] = '" & txtCustomer _
            & "' AND [Price Type] <> '' ORDER BY [Effective Date]"

        'But when I do this, it works fine.
        sSQLQuery = "SELECT DISTINCT [Price Type] FROM Prices WHERE KitchenID = '" & txtKitchenID _
            & "' AND [Customer ID] = '" & txtCustomer & "'"

         'so I am guessing it has a problem with the last two lines
         'but I don't see what.
 
Last edited:
It's your SELECT DISTINCT statement, but you know that now already. :p ;)
 
Last edited:
Hehe I guess you are a member of both forums. Thanks for the reply. :)
 
lol, yeah - more of a lurker on the other one. Just stopped cause I knew I'd seen the thread title before. :cool:
 

Users who are viewing this thread

Back
Top Bottom