Problem setting RecordSource from SQL statement

  • Thread starter Thread starter MRichards
  • Start date Start date
M

MRichards

I'm trying to change the record source property within a form (which I've
done before) based on user-entered search criteria, but it is not finding
the table -- the same table that was the original record source. I get this
message:
"The Microsoft Jet database engine cannot find the input table or query
'SELECT * FROM tblRecords'. Make sure it exists and that its name is spelled
correctly."

The code looks like this:

strRecSource = "SELECT * FROM tblRecords " _
& "WHERE LastName like '" & strName & "'"

Me.RecordSource = strRecSource
Me.Requery

I have verified spelling (even copying/pasting from the actual table name).
I have commented out the WHERE clause so that it is just searching for a
table. I can copy this statement into a blank query in SQL view and it works
fine.

Any ideas are appreciated.

Thanks,
Mark
 
as a possible alternative. . Why not create a querydef with SQL as follows
"SELECT * FROM tblRecords" (the source of the form being the query name.
Then change the SQL of the query def.
 
Additionally...

I can just set Me.RecordSource = qryQueryName and it returns a similar
"can't find the record source" error message.
 
Back
Top