Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 2002: Condition applied before executing the report

Status
Not open for further replies.

dreman

Programmer
Joined
Jan 16, 2002
Messages
272
Location
US
I have an entry form to select all kinds of conditions.
What I do is accumulate the conditions in a string (WhereCondition) and then invoke it into a report using
DOcmd.Openreport "reportname",,WhereCondition.
What I want to do is get the count of records returned based on the user conditions before invoking the report. (Kind of a filter)
(ie: WhereCondition= " (city = FL) AND DATE Between #" & FromDATE "# And #" & ToDate "#)"
The reason is to get info to the user of how many records where selected before the report get executed.
Please advise.
Thank you.
Dré
 
Assemble your string, then open a recordset and do a recordcount before opening the report.

HTH
Lightning
 
Lightining:
I am still new using Access 02 or VB, can you give me and example please.

StrSql = "Select count(*) from " & Table & " Where " & CondtionCollected

Thank you.
Dré
 
There is a good example of how to do this in the VB Help file. Open any code module, then select the Help|Microsoft Visual Basic Help option from the menu.

When the Help file opens, type in Recordcount Property and search. This should return 2 topics - the Recordcount Property (ADO) and Recordcount Property (DAO). Which method you use depends on your Reference library settings. Since you say you are new to VB coding, you should probably use the (ADO) method.

HTH
Lightning
 
I will give it a shot or run it via a macro.
thank you.
dré
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top