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

Datasheet - After Filter Event

Status
Not open for further replies.

TorF

Programmer
Sep 30, 2002
83
FR
Normally filter in datasheet works correctly: the Form_Current event give me the possibility to know the new selected current record.

But when filter "delete" all records (there is 0 record in datasheet), no event is sended.
Then my system stays in the same state than before filtering... that is VERY bad.

Unfortunatly Form_ApplyFilter is sended before filtering.
Then it is possible to start, in Form_ApplyFilter event, a timer to check datasheet state in 1 (or more) seconds, but filter duration is not predictable and so cannot work.

Is there a possibility to detect the end of a filter processus ?
Or to detect that no record is selected ?

Thanks
 
I use the form's OnCurrent event for this. If you filter a form and no records are returned the form displays a blank, or new, record. So in the form's OnCurrent event you can use somthing like:

Code:
If Me.NewRecord Then
    'Put your code here
End If

Warning: of course, this code will also run when you actually do create a new record, so this might impose a limitation on what you want to put inside the If loop.

HTH [pc2]
 
Haha yes, that works !
The Form_Current event is detected.

But in fact, i set the property "Allow Additions" to No, and then the Form_Current event is not detected...
I don't the user to add new records.

Another solution ?
 
Finally i found an idea that works, based on your solution mp9, when Form AllowAdditions property is set to No:

'Active AllowAddition juste before filtering
Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
Me.AllowAdditions = True
End Sub

'NoRecord will indicate if filter "delete" all records
Private Sub Form_Current()
Dim NoRecord As Boolean

NoRecord = Me.NewRecord
Me.AllowAdditions = False
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top