qwkslvr1999
Registered User.
- Local time
- Today, 14:17
- Joined
- Jan 21, 2002
- Messages
- 42
I found the Microsoft QBF sample and edited it. I am getting a Syntax error in one of the lines I added and wondering if it is really possible to do it. The error happens in the line that has the datediff function. I would like to be able to enter something like <=30 or >=30, etc. in the search form through an unbound text box [AGE]. Everything else works fine. What could be the problem?
Thanks in advance!
=============================
Private Sub Command4_Click()
Dim mydatabase As Database
Dim myquerydef As QueryDef
Dim where As Variant
Set mydatabase = CurrentDb()
If ObjectExists("queries", "qrydynamic_QBF") = True Then
mydatabase.QueryDefs.Delete "qrydynamic_QBF"
mydatabase.QueryDefs.Refresh
End If
where = Null
where = where & (" AND [city]= '" + Me![citysearch] + "'")
where = where & (" AND [Dx]='" + Me![Dxsearch] + "'")
ERROR >> where = where & (" AND (DateDiff("yyyy",[DOB],Now()))" + Me![Age])
Set myquerydef = mydatabase.CreateQueryDef("qrydynamic_QBF", "SELECT TABLE1.*, TABLE2.* FROM TABLE1 INNER JOIN TABLE2 ON TABLE1.ID = TABLE2.ID " & (" where " + Mid(where, 6) & ";"))
DoCmd.OpenQuery "qrydynamic_QBF"
End Sub
=============================
[This message has been edited by qwkslvr1999 (edited 06-07-2002).]
Thanks in advance!
=============================
Private Sub Command4_Click()
Dim mydatabase As Database
Dim myquerydef As QueryDef
Dim where As Variant
Set mydatabase = CurrentDb()
If ObjectExists("queries", "qrydynamic_QBF") = True Then
mydatabase.QueryDefs.Delete "qrydynamic_QBF"
mydatabase.QueryDefs.Refresh
End If
where = Null
where = where & (" AND [city]= '" + Me![citysearch] + "'")
where = where & (" AND [Dx]='" + Me![Dxsearch] + "'")
ERROR >> where = where & (" AND (DateDiff("yyyy",[DOB],Now()))" + Me![Age])
Set myquerydef = mydatabase.CreateQueryDef("qrydynamic_QBF", "SELECT TABLE1.*, TABLE2.* FROM TABLE1 INNER JOIN TABLE2 ON TABLE1.ID = TABLE2.ID " & (" where " + Mid(where, 6) & ";"))
DoCmd.OpenQuery "qrydynamic_QBF"
End Sub
=============================
[This message has been edited by qwkslvr1999 (edited 06-07-2002).]