Hello All,
I would like to replace the WHERE clause of a query using VBA, based on the value in another form. In the book I have, it said to do it something like this:
When I try to run the code, I get an error saying "Compile Error: Sub or Function not defined." It then highlights the phrase replacewhereclause. I thought this was a command in VBA (the book implies that it is). Does anyone know how to fix this?
I would like to replace the WHERE clause of a query using VBA, based on the value in another form. In the book I have, it said to do it something like this:
Code:
'Change qryNewBusinessYTD
Dim strSQL As String
Dim qdf As QueryDef
Dim db As Database
Set db = CurrentDb
Set qdf = db.QueryDefs("qryNewBusinessYTD")
strSQL = "[Billing Effective Date] <= #" & Me.txtAsOfDate & "#"
'Change Where Clause
qdf.sql = replacewhereclause(qdf.sql, strSQL)
Set qdf = Nothing
Set db = Nothing