Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax Error on Select 1

Status
Not open for further replies.

techsponge

Technical User
Feb 8, 2006
37
US
I have the following code for a label. when the user clicks the label above a column it will resort the continuous form by the column clicked.

I am getting a Syntax error message on the select statement, although when I paste the SQL into a new query it runs fine?

Begin SQL
Code:
Me.Form.RecordSource = "SELECT TblMasterGameList.FrmName, TblMasterGameList.TktType, TblMasterGameList.TktBin, TblMasterGameList.TopPays, TblMasterGameList.PurchDate, TblMasterGameList.TktPrice, TblMasterGameList.TktCount, TblMasterGameList.GameName, TblMasterGameList.WashStampNum FROM TblMasterGameList WHERE (((TblMasterGameList.FrmName) Not Like "TPGC*") AND ((TblMasterGameList.TktType)="5W") AND ((TblMasterGameList.TktBin) Is Null) AND ((TblMasterGameList.TktPrice)=1) AND ((TblMasterGameList.CloseDate) Is Null))ORDER BY TblMasterGameList.GameName;"


Any Ideas?

Code:
Private Sub lblName_Click()
'change the recordset
Me.Form.RecordSource = "SELECT TblMasterGameList.FrmName, TblMasterGameList.TktType, TblMasterGameList.TktBin, TblMasterGameList.TopPays, TblMasterGameList.PurchDate, TblMasterGameList.TktPrice, TblMasterGameList.TktCount, TblMasterGameList.GameName, TblMasterGameList.WashStampNum FROM TblMasterGameList WHERE (((TblMasterGameList.FrmName) Not Like "TPGC*") AND ((TblMasterGameList.TktType)="5W") AND ((TblMasterGameList.TktBin) Is Null) AND ((TblMasterGameList.TktPrice)=1) AND ((TblMasterGameList.CloseDate) Is Null))ORDER BY TblMasterGameList.GameName;"
'set the color to red to show the column sort order
Me.lblName.ForeColor = vbRed
'set the color to black to show the column is not sorted
Me.LblDateRec.ForeColor = vbBlack
Me.LblCount.ForeColor = vbBlack
Me.LblTopPay.ForeColor = vbBlack
Me.LblStamp.ForeColor = vbBlack
End Sub
 
How are ya techsponge . . .

Perhaps this missing space in red:
Code:
[blue]Is Null))[COLOR=red red] [/color]ORDER BY TblMasterGameList.GameName;"[/blue]


Calvin.gif
See Ya! . . . . . .
 
Thanks AceMan,

Gave that a try and immediatly got the following:

"Expected: end of statement" and it hightlighted the following:

Code:
Me.Form.RecordSource = "SELECT TblMasterGameList.FrmName, TblMasterGameList.TktType, TblMasterGameList.TktBin, TblMasterGameList.TopPays, TblMasterGameList.PurchDate, TblMasterGameList.TktPrice, TblMasterGameList.TktCount, TblMasterGameList.GameName, TblMasterGameList.WashStampNum FROM TblMasterGameList WHERE (((TblMasterGameList.FrmName) Not Like [red][b]"TPGC*"[/b][/red]) AND ((TblMasterGameList.TktType)="5W") AND ((TblMasterGameList.TktBin) Is Null) AND ((TblMasterGameList.TktPrice)=1) AND ((TblMasterGameList.CloseDate) Is Null)) ORDER BY TblMasterGameList.GameName;"
 
And what about this ?
Me.Form.RecordSource = "SELECT FrmName, TktType, TktBin, TopPays" _
& ", PurchDate, TktPrice, TktCount, GameName, WashStampNum" _
& " FROM TblMasterGameList" _
& " WHERE FrmName Not Like [!]'[/!]TPGC*[!]'[/!] AND TktType=[!]'[/!]5W[!]'[/!] AND TktBin Is Null" _
& " AND TktPrice=1 AND CloseDate Is Null ORDER BY GameName"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top