RecordCount please help! im stuck

greenfalcon

Registered User.
Local time
Yesterday, 23:27
Joined
Aug 22, 2006
Messages
34
Thanks for looking at my post. What I have done is this, i have built a custom search form for my access database. What i need is a textbox that shows how many records will show up if the user clicks generate form.. I want this textbox to update every time the person changes his search criteria. For example

the person wants to search by address, by typing in

Gold into the address textbox the recordcount textbox would show the user if he were to press generate form he would get

1200 records

now if he changes the address to
GoldStone -- the recordcount textbox would then update to show only

14 records would be shown if he/she generated the form...
Here is my current code

***********
Set db = CurrentDb
Set qdf = db.QueryDefs("MainDB_Search")

For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm

Set rs = qdf.OpenRecordset(dbOpenDynaset)
rsCount = rs.RecordCount

MsgBox (rsCount)
txtGenerateReport.Value = rsCount

************
Now the problem with this code is that it works the first time the user types in search criteria, however when he/she tries to change it from Gold to Goldstone -- nothing happens, it runs the code above and returns 1200 records instead of the correct 14...

Please help :)

Thanks

Jason
 
The record count property is a little confusing. It does not tell you how many records are in the recordset. Instead it is the number of records you have accessed in the recordset.
 
is there any way to reset this or get it to work every time a user updates the address search field?
 
Everytime you open up a new recordset it should be set to zero. You will need to step through each record to get an accurate record count. Look it up in VBA help.
 
Well i got the code to work by changing the event from On Change to After Update.

Works great.

Thanks for attempting to help me.

Jason
 

Users who are viewing this thread

Back
Top Bottom