Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

How make navigation buttons appear if more than one filtered record

I have a form with the navigation buttons not visible by default.  But if there is more than one record to be viewed on the form I want the navigation buttons to appear.

How can I do this?

--Steve
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

You could use the Form_Load event and do something like:

Private Sub Form_Load

    me.NavigationButtons = me.recordsetclone.recordcount > 1

End if

ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
you mention "more than one filtered record" in your question.

How are you "filtering" the recordset?  Are you doing this with the optional "WhereCondition" parameter of the OpenForm method, or do you actually have a filter functionality on your form?  If the latter, then you would need to include this method within the code sequence you are using to filter the form as well as in the load event.

That's why I'm thinking the Current event, because even if when you load, there is only one record, that could change during usage of the form, so the Current event covers both cases.

mx
Joe,

That would, of course, work.  I just didn't see a need to do it on every record.
But 'every record' is when it could change dynamically for 1 to >1 ... if adding, deleting, etc.

If you load and there is one, nav is off. But if you add, now you have two. nav is still off. oops.

mx
Avatar of SteveL13

ASKER

The form is "filtered" by a query which drives the information to the form.
That's reasonable, and if you delete, same logic applies.

I almost never use the built-in navigation buttons, and have a routine (as I'm sure you do) I use to control the status of my custom navigation buttons, which gets called from a variety of places (Form_Current, Form_Dirty, MoveWhere, ...)
Steve ... pretty sure the Q has been answered.

Dale ... yes, I mentioned deleting above ...

mx