How are you assigning a value to sWhereClause? Also, do you assign the
SQL
of the query if sWhereClause is blank?
FWIW, while it's not what's causing your problems, there's no real reason
for the v. in v.*, the v before the word WHERE nor the terminating
semicolon. Also, just in case you ever use the (poor, in my opinion)
possibility of having embedded blanks in your query or field names, you
might put square brackets, just in case:
If Len(sWhereClause) > 0 Then
strSQL = "SELECT * FROM [" & qry & "] WHERE " & sWhereClause & _
" ORDER BY [" & nm & "]"
CurrentDb.QueryDefs("pqPCriteria").SQL = strSQL
End If
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
smk23 said:
QuickSearch was working fine until I added the last two arguments. It
used
to
be QuickSearch(Me.Id) and that works fine. I wanted to vary the
underlying
query used and here is where those new arguments appear:
If sWhereClause <> "" Then
strSQL = "SELECT v.* FROM " & qry & " v WHERE " & sWhereClause &
_
" ORDER BY " & nm & ";"
CurrentDb.QueryDefs("pqPCriteria").SQL = strSQL
End If
I could abort the whole thing and just write individual SELECT
statements
if
that is better in the long run (maintenance, performance, etc).
Thanks for the help.
Sam
:
Without seeing the details of the QuickSearch routine, it's difficult
to
know what your problem is.
The use of "Me.ID" looks suspect to me: that's going to pass the
literal
string "Me.ID" to the function, rather than whatever value that field
contains.
It's entirely possible that qry is supposed to be an actual SQL
statement,
not the name of a query.
Are you sure that QuickSearch actually works?
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
I am passing values for search criteria, query and sort order for the
query
via this code:
Public Sub QuickSearch(strSearch As String, qry As String, ord As
String)
When I try to pass values to the function using this line, I get a
syntax
error.
QuickSearch("Me.ID", "vwSMKPatientLookUp", "nm")
The message says there is a "=" sign missing. I've tried it with and
without
the quote marks. Me.ID is a string value the user types in.
Thanks for looking at this.
sam