Search syntax

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to get a simple search form to work, and I know there is a syntax
problem, I have been working on this for +3 weeks and I am absolutely stuck
now. In an If statement, this is one of my else's:

Category is a field name, qManufacturer (by alpha) is the query

Option Compare Database
Option Explicit
Dim db As Database
Dim rs(3) As Recordset
Dim sql As String
---------
ElseIf Me.Category <> "" Then

sql = "SELECT * FROM 'qManufacturer (by alpha)'"
sql = sql & "WHERE Category" = Me.Category
Set rs(1) = db.OpenRecordset(sql, dbOpenTable)
Set rs(1) = db.OpenRecordset(sql, dbOpenSnapshot)
On Error GoTo Err_FindRecords_Click
DoCmd.OpenTable (rs(1))

ElseIf...

It always returns "...The database engine couldn't find the object 'False'
.... ", but that is the only way I can get the SELECT syntax to work. Any
advice is SUPER appreciated (=. Thank you.
 
Is this an exact "cut & paste"? There's no ampersand (&) after
Category = , and the quotes are in the wrong place. It should read:
sql = sql & "WHERE Category = '_" & Me.Category & "_'_"

Take out the underscores, I put them in there so you could tell the
difference between single and double quotes.
 
Back
Top