SQL Syntax Problem

  • Thread starter Thread starter DS
  • Start date Start date
D

DS

Having a problem with SQL statement,I think its with the [FName]& "
" &[LName] Section....
Any Help Appreciated
Thanks
DS

With Me.ListToGo
.RowSource = "SELECT PCenter.TableID,[FName]& " " &[LName] AS
Expr, Sales.SalesID, PCenter.TableName, Sales.Cancelled,
Sales.SalesServer, Sales.Paid " & _
"FROM PCenter INNER JOIN (Customers INNER JOIN Sales ON
Customers.CustomerID = Sales.CustomerNum) ON PCenter.TableID =
Sales.TableNumber " & _
"GROUP BY PCenter.TableID, [FName] & " " & [LName], Sales.SalesID,
PCenter.TableName, Sales.Cancelled, Sales.SalesServer, Sales.Paid " & _
"HAVING (((PCenter.TableName) Like 'Delivery') AND
((Sales.Cancelled)=0) AND
((Sales.SalesServer)=[Forms]![PCenter]![Server]) AND ((Sales.Paid)=0));
End With
 
DS said:
Having a problem with SQL statement,I think its with the [FName]& "
" &[LName] Section....
Any Help Appreciated
Thanks
DS

With Me.ListToGo
.RowSource = "SELECT PCenter.TableID,[FName]& " " &[LName] AS
Expr, Sales.SalesID, PCenter.TableName, Sales.Cancelled,
Sales.SalesServer, Sales.Paid " & _
"FROM PCenter INNER JOIN (Customers INNER JOIN Sales ON
Customers.CustomerID = Sales.CustomerNum) ON PCenter.TableID =
Sales.TableNumber " & _
"GROUP BY PCenter.TableID, [FName] & " " & [LName],
Sales.SalesID, PCenter.TableName, Sales.Cancelled, Sales.SalesServer,
Sales.Paid " & _ "HAVING (((PCenter.TableName) Like 'Delivery')
AND ((Sales.Cancelled)=0) AND
((Sales.SalesServer)=[Forms]![PCenter]![Server]) AND
((Sales.Paid)=0)); End With

Change the occurrences of

[FName] & " " &[LName]

to

[FName] & ' ' &[LName]

(that is, replacing the double-quotes with single-quotes), to keep
Access from getting those quotes confused with the ones that define the
literal string you're building for the SQL statement.
 
Anytime you need to put quotes inside of quotes, you need to double up the
inside ones.

.RowSource = "SELECT PCenter.TableID,[FName]& "" "" &[LName] AS ....
 
Dirk said:
Having a problem with SQL statement,I think its with the [FName]& "
" &[LName] Section....
Any Help Appreciated
Thanks
DS

With Me.ListToGo
.RowSource = "SELECT PCenter.TableID,[FName]& " " &[LName] AS
Expr, Sales.SalesID, PCenter.TableName, Sales.Cancelled,
Sales.SalesServer, Sales.Paid " & _
"FROM PCenter INNER JOIN (Customers INNER JOIN Sales ON
Customers.CustomerID = Sales.CustomerNum) ON PCenter.TableID =
Sales.TableNumber " & _
"GROUP BY PCenter.TableID, [FName] & " " & [LName],
Sales.SalesID, PCenter.TableName, Sales.Cancelled, Sales.SalesServer,
Sales.Paid " & _ "HAVING (((PCenter.TableName) Like 'Delivery')
AND ((Sales.Cancelled)=0) AND
((Sales.SalesServer)=[Forms]![PCenter]![Server]) AND
((Sales.Paid)=0)); End With


Change the occurrences of

[FName] & " " &[LName]

to

[FName] & ' ' &[LName]

(that is, replacing the double-quotes with single-quotes), to keep
Access from getting those quotes confused with the ones that define the
literal string you're building for the SQL statement.
That Worked! Thanks
DS
 
Douglas said:
Anytime you need to put quotes inside of quotes, you need to double up the
inside ones.

.RowSource = "SELECT PCenter.TableID,[FName]& "" "" &[LName] AS ....
That also worked!
Thanks
DS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top