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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quick SQL Problem

Status
Not open for further replies.

fabby1

Technical User
Mar 9, 2004
206
0
0
GB
Can anybody sus out what is wrong with this

Code:
Set qdfTemp = dbsCurrent.CreateQueryDef("")




With qdfTemp
.SQL = "SELECT T.ITIME, T.LINE, T.ISLAND, T.TAGVALUE-Nz(V.TAGVALUE,0) AS Total " _
     & "FROM TMP_DAILY_TABLE AS T INNER JOIN TMP_DAILY_TABLE AS V ON (T.DISPLAYNAME=V.DISPLAYNAME) AND (Format(T.IDATE,""yyyymmddhhnn"")=Format((V.IDATE+#12/30/1899 0:15:0#),""yyyymmddhhnn"")) " _
     & "WHERE T.DISPLAYNAME like " & G_Desk & ""
End With

Set rstTemp = qdfTemp.OpenRecordset

With rstTemp
   .MoveLast
   .MoveFirst
End With

I get the error

Code:
Run time error '3075'

Syntax error (missing operator) in query expression 'T.DISPLAYNAME like Dest 41'.


Thanks a bunmch

P
 
Replace this:
& "WHERE T.DISPLAYNAME like " & G_Desk & ""
By this:
& "WHERE T.DISPLAYNAME like '" & G_Desk & "'"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Mr Fix it strikes again

Thanks

P
 
Something for long term might be to change it into parameterized query.

Instead of:
& "WHERE T.DISPLAYNAME like '" & G_Desk & "'"

try:
& "WHERE T.DISPLAYNAME like [sG_Desk]"

To set the parameter [sG_Desk]
you might then do:
Dim param1 As DAO.Parameter
Set param1 = qdfTemp.Parameters!sG_Desk
param1 = G_Desk

This way you won't have to remember to check for quotes inside G_Desk
 
Opps you would need something like this at the beginning of the query string:

sql = "PARAMETERS sG_Desk Text ( 255 );
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top