S
Sid
One more....
What might be wrong with my syntax, as I try to use the Find "*" at the end
of a line like this:
strSQL = strSQL & " AND Field1 = " & " LIKE "*"" ?
This line would follow a line that works perfectly alone like:
strSQL = strSQL & " WHERE Field2 = " & """" & Me!Select & """"
Thanks
I'm trying to string several strSQLs together for a custom report query.
What might be wrong with my syntax, as I try to use the Find "*" at the end
of a line like this:
strSQL = strSQL & " AND Field1 = " & " LIKE "*"" ?
This line would follow a line that works perfectly alone like:
strSQL = strSQL & " WHERE Field2 = " & """" & Me!Select & """"
Thanks
I'm trying to string several strSQLs together for a custom report query.
Sid said:Thanks Ken
I just changed the field name in the data table to Groups.
Everything is working amazingly well now.
Thanks for your time, that was a weird one. I need to learn all SQL &
other reserved words to avoid.
Sid
lostKen Snell said:The reason Group doesn't work is because it's a "reserved word" in
ACCESS....so ACCESS thinks that you're calling that special use of the word,
not using your field name. Surround Group with [ ] in the SQL statement and
it should work ok...better thing to do though is to not use it as a field
name.
See this MS KB article for more info:
ACC2002: Reserved Words in Microsoft Access
http://support.microsoft.com/default.aspx?scid=kb;EN-US;286335
--
Ken Snell
<MS ACCESS MVP>
butSid said:Amazing!
I found my problem Ken &/or Michael.
The word "Group"(my field name) in my SQL caused the problem. I named it
Groups & it works!
Thanks
Michael
Would that have been the reference: Microsoft ADO Ext. 2.1 for DDL and
Security ?
I selected it, but I still get the compile error.
My SQL problem is running those strings separately, (in response to
selections on my project form), but my test was just trying each
individually. The Me!SelectPnt one worked, while the Me!SelectGrp has
never
worked. This is awful, there must be a non-experimental syntax I can
obtain
for SQL.
Thanks
Hi Sid,
I'm not quite sure, but you can try this:
strSQL = strSQL & " WHERE Label = " & """" & Me!SelectPnt & """"
strSQL = strSQL & " AND Group = " & """" & Me!SelectGrp & """"
In the WHERE statement, you can have a combination of different
conditions,
all linked by eithere AND or OR. I put here AND for an example,
youreferencecan
also have a OR in place, depending of how you want to select the data.
Use
AND when you want both conditions to be true at the same time, OR for
either
one of them to be true.
For the "Dim rst As ADODB.Recordset" to work, you have to
ADOin
you vba module.
Hope this might help
Ken
I have learned a bit since my posting yesterday. I was trying to
display
a
string variable (in a form text box for a test)with a string of SQL
characters, couldn't. But now I know the SQL syntax is super
critical.
I
managed to make the following work:
-----
Private Sub Command37_Click() ' SQL Creator Test
Dim strSQL As String
Dim dbs As Database
Dim qdf As QueryDef
'DoCmd.DeleteObject acQuery, "qryTempRptQry"
strSQL = "SELECT * FROM qryReportLog1"
'Works by itself
'strSQL = strSQL & " WHERE Label = " & """" & Me!SelectPnt & """"
'Works by itself
'strSQL = strSQL & " WHERE Group = " & """" & Me!SelectGrp & """"
'WON'T
work
Set dbs = CurrentDb()
Set qdf = dbs.CreateQueryDef("qryTempRptQry", strSQL)
DoCmd.OpenQuery "qryTempRptQry", , acReadOnly
Set qdf = Nothing
Set dbs = Nothingtryingto input
at: double
up of
the My
goal Glad
you but
keep run
it