Filtering a form - wait

C

cyb3rwolf

Hello everyone,

I've run into a problem i'm not sure how to solve. I have a form that with
the click of a button filters the form based on the value in a text box. I
also have my own controls for record navigation for navigating through the
filtered form. There is a text box called "Total Records" that is supposed
to display the total number of records in the form after it is filtered using
Me.Recordset.RecordCount as the source. This doesn't appear to work
properly; for example with one search, Me.Recordset.RecordCount returns "2"
when there are a total of 4 records. It appears that it is executing the
code before the filter completes. Anybody point me in the right direction on
this? Here is my coding:


Private Sub Command221_Click()
Me.Progress = "Searching..."
DoCmd.ApplyFilter , "[Customer Order Number]='" & Me.WON & "'"
'Me.Vendor = Me.VendorOrder
Me.ITSDate = Null
Me.ITInvalid_Tracking = Null
Me.Total_Records = Me.Recordset.RecordCount
Me.RecordNumber = Me.CurrentRecord
Me.Progress = "Search Complete. " & Me.Recordset.RecordCount & " Record(s)
found for " & Me.WON
If Me.Recordset.RecordCount = 0 Then
MsgBox "Order Not Found!"
Me.Email = Null
Me.Notes = Null
End If
[Replacement Partsb].Requery
[Vendor Carrier Information].Requery
End Sub
 
C

cyb3rwolf

Perfect. Solved. Thank you so much for your help! :)

Marshall Barton said:
cyb3rwolf said:
I've run into a problem i'm not sure how to solve. I have a form that with
the click of a button filters the form based on the value in a text box. I
also have my own controls for record navigation for navigating through the
filtered form. There is a text box called "Total Records" that is supposed
to display the total number of records in the form after it is filtered using
Me.Recordset.RecordCount as the source. This doesn't appear to work
properly; for example with one search, Me.Recordset.RecordCount returns "2"
when there are a total of 4 records. It appears that it is executing the
code before the filter completes. Anybody point me in the right direction on
this? Here is my coding:


Private Sub Command221_Click()
Me.Progress = "Searching..."
DoCmd.ApplyFilter , "[Customer Order Number]='" & Me.WON & "'"
'Me.Vendor = Me.VendorOrder
Me.ITSDate = Null
Me.ITInvalid_Tracking = Null
Me.Total_Records = Me.Recordset.RecordCount
Me.RecordNumber = Me.CurrentRecord
Me.Progress = "Search Complete. " & Me.Recordset.RecordCount & " Record(s)
found for " & Me.WON
If Me.Recordset.RecordCount = 0 Then
MsgBox "Order Not Found!"
Me.Email = Null
Me.Notes = Null
End If
[Replacement Partsb].Requery
[Vendor Carrier Information].Requery
End Sub


RecordCount only returns the number of records that have
been "accessed" by some internal process, by code that
forces records to be accessed or by users doing something
such as scrolling.

In your case, add the line:
Me.RecordsetClone.MoveLast
before the RecordCount line.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top