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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record count 1

Status
Not open for further replies.
Jan 22, 2001
124
US
I'm attempting to count the number of records diplayed on a form. This forms' record source is a query. The query results are based on a parameter. The paramter is located in the "Date Completed" field: Between [Enter Begin Date] And [Enter End Date]. When the form opens, a Run-time error '64479' occurs. The message states "The expression you entered as a query parameter produced this error: The object doesn't contain the Automation object 'Enter Begin Date'." I have used the same code on forms based on non-parameter queries to get a record count, and they worked fine. Any ideas on how to get around this. Any and all help will be greatly appreciated. Thanks in advance.

--Rob
 
Had this problem a few times,

In your query go to query on the menu bar and click on parameters, type in the fieldname where the date comes from i.e. forms![your form]![Enter Begin Date] and forms![your form]![Enter End Date] (2 separate entries)and specify the data type for both as date/time, hopefully this will sort the problem

regards
Leckie
 
Rob,

The approach below may not be the most efficient but
seems to work. I have attached the code the "click"
event of "Button1" on my form but you should be able to use
the "Rst.RecordCount" wherever you desire. This uses
the Form's RecordsetClone property. This is a pretty
neat animal. It will capture the count of however many
records the user has on the form at a given time, so
will work when they filter to a subset of the original
records.

Hope this works for you.

Keith



Private Sub Button1_Click()
Dim Rst As Recordset
Dim Response As String
Set Rst = Me.RecordsetClone
Response = MsgBox("Records on this form: " & Rst.RecordCount, vbOKOnly)
Rst.Close
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top