Is there a way to filter moving to the next record?

WindSailor

Registered User.
Local time
Yesterday, 22:32
Joined
Oct 29, 2003
Messages
239
I have tried:

DoCmd.GoToRecord , , acNext
DoCmd.ApplyFilter , (Me.Length = Me.Combo30.Value) And (Me.Height = Me.Combo32.Value) And (Me.Width = Me.Combo34.Value)

These are numerical values, I have tried various ways and I just can't seem to make it work.

Thanks
 
I should have said that I used that on command buttons trying to filter the records when moving to the next record. It obviously didn't work.

Ok... got it to work doing the following steps...


Use this on Form1 properties… Data tab… Filter…

Length = Forms![Form1]![Combo30] and Height = Forms![Form1]![Combo32] and Width = Forms![Form1]![Combo34]

And put this on the forms “On Current” event…

Me.FilterOn = True

And on the "Click" event on each combo box...

DoCmd.Requery


This will filter the form based on a query to criteria listed in the above combo boxes, assuming “Length”, “Height”, and “Width” are fields in the query using command buttons to go to the next, previous record.

I am sure there are other ways, but this one works.

:)

If there are other ways I would sure like to see them.
Thanks
 
Last edited:
Wind,

Code:
strCriteria = "[Length] = " & Forms![Form1]![Combo30] & " and " & _
              "[Height] = " & Forms![Form1]![Combo32] & " and " & _
              "[Width]  = " & Forms![Form1]![Combo34]

Wayne
 
1) have a query that is based on the current field. if having problems see attachment for info on how to set criteria to a value in a text field in a form.
2) set the form to have the query as the record source
3) in your code:

Code:
DoCmd.GoToRecord , , acNext
me!sfrm_your_subform.requery 
' or 
me.requery 'if not in a subform

Does this help? Please respond.
 

Attachments

Last edited:
Thanks Wayne
And YES Thanks Smercer...
That did help Immensely...! I was so stuck on applying filters and trying to do it by code, I totally forgot about changing the query to a parameter query and using the three combo boxes as criteria and then use code. Excellent!
:o
I think it was Milo who said on another post that Access teaches you to think laterally... Very true!
 
Last edited:

Users who are viewing this thread

Back
Top Bottom