Syntax Help Please

wizcow

Registered User.
Local time
Today, 15:39
Joined
Sep 22, 2001
Messages
236
I have made a query that does what I want.
I have coppied it from the SQL window.

Code:
SELECT *, [CustomerLast] & ", " & [Title] & " " & [CustomerFirst] AS SoldToCustomer
FROM Customers;

When I insert it into my code it doesn't work.
I think I am haveing some trouble with the " and the ,

Code:
Dim strRecordSource As String
    
    strRecordSource = "SELECT *, [CustomerLast] & ", " & [Title] & " " & [CustomerFirst] AS SoldToCustomer" & _
                      "  FROM Customers;"

What do I have to change here?

Thanks
Tom
 
Did you set a record source too? You probably have to be more specific. VBA doesn't know where [CustomerLast] etc are coming from. try something along the lines of [TableName]![CustomerLast]. Understand?

What is the point of this VBA code? If a query already does it, why do it in VBA too?
 
I think the "inner" double quotes around the comma and space need to be single quotes.
 
"SELECT *, [CustomerLast] & "", "" & [Title] & "" "" & [CustomerFirst] AS SoldToCustomer
FROM Customers;"
 

Users who are viewing this thread

Back
Top Bottom