D
Dennis Snelgrove
I've got a report where I need to get the record count of the
RecordSource's query. The query itself pulls values from 4 different
textboxes on a form for it's criteria. I used the following code to attempt
to achieve the count, but I'm getting the usual error about needing values
for the 4 parameters when I hit the "Set rs = " line. I've run into this
problem many time before and I understand why it's happening. In the past I
have simply passed the SQL string directly to the OpenRecordset method and
substituted the values into the string, but in this case I need to use the
Me.RecordSource in case the query gets changed. I don't want to have to keep
re-opeing the VBA to reprogram the SQL string directly. Is it possible to
somehow tell the query to resolve the parameters?
Thanks for any insights...
Dim rs As DAO.Recordset
Dim QueryName As String
QueryName = Me.RecordSource
Set rs = CurrentDb.OpenRecordset(QueryName)
With rs
.MoveLast
.MoveFirst
End With
RecordSource's query. The query itself pulls values from 4 different
textboxes on a form for it's criteria. I used the following code to attempt
to achieve the count, but I'm getting the usual error about needing values
for the 4 parameters when I hit the "Set rs = " line. I've run into this
problem many time before and I understand why it's happening. In the past I
have simply passed the SQL string directly to the OpenRecordset method and
substituted the values into the string, but in this case I need to use the
Me.RecordSource in case the query gets changed. I don't want to have to keep
re-opeing the VBA to reprogram the SQL string directly. Is it possible to
somehow tell the query to resolve the parameters?
Thanks for any insights...
Dim rs As DAO.Recordset
Dim QueryName As String
QueryName = Me.RecordSource
Set rs = CurrentDb.OpenRecordset(QueryName)
With rs
.MoveLast
.MoveFirst
End With