SQL Statement Selecting Records and Creating Query Def

Mechele

Registered User.
Local time
Today, 23:22
Joined
Jan 25, 2002
Messages
121
I'm getting a syntax error from the following:

Dim StrSQL As String
Dim QDF As QueryDef

Me!Temp = Me!List1

If Me!Temp = "The Westin La Cantera" Then
StrSQL = "SELECT data.NameofRegistrant, Data.[Hospital\FacilityName], Data.Address, Data.Address1, Data.City, Data.State, Data.ZipCode" _
& "FROM Data" _
& "WHERE Data.Westin = Yes;"
Set QDF = CurrentDb.QueryDefs("MailingListbyHotelQuery")
QDF.SQL = StrSQL
QDF.Close
End If

What am I doing wrong?:mad:
 
Try using "CreateQueryDef" instead of "QueryDef"
 
I think you need space in you SQL string, before From and Where.

StrSQL = "SELECT data.NameofRegistrant, Data.[Hospital\FacilityName], Data.Address, Data.Address1, Data.City, Data.State, Data.ZipCode" _
& " FROM Data" _
& " WHERE Data.Westin = Yes;"
 

Users who are viewing this thread

Back
Top Bottom