Syntax Help Please (1 Viewer)

wizcow

Registered User.
Local time
Today, 10:09
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
 

o1110010

Registered User.
Local time
Today, 11:09
Joined
Mar 6, 2004
Messages
182
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?
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 09:09
Joined
Aug 30, 2003
Messages
36,125
I think the "inner" double quotes around the comma and space need to be single quotes.
 

Mile-O

Back once again...
Local time
Today, 17:09
Joined
Dec 10, 2002
Messages
11,316
"SELECT *, [CustomerLast] & "", "" & [Title] & "" "" & [CustomerFirst] AS SoldToCustomer
FROM Customers;"
 

Users who are viewing this thread

Top Bottom