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
SteveL13Asked:
Who is Participating?
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:


How about this:

Private Sub Form_Current()
    If Me.RecordsetClone.RecordCount > 1 Then
        Me.NavigationButtons = True
    Else
        Me.NavigationButtons = False
    End If
End Sub

mx
0
 
Dale FyeCommented:
You could use the Form_Load event and do something like:

Private Sub Form_Load

    me.NavigationButtons = me.recordsetclone.recordcount > 1

End if

0
 
Dale FyeCommented:
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.

0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
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
0
 
Dale FyeCommented:
Joe,

That would, of course, work.  I just didn't see a need to do it on every record.
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
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
0
 
SteveL13Author Commented:
The form is "filtered" by a query which drives the information to the form.
0
 
Dale FyeCommented:
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, ...)
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Steve ... pretty sure the Q has been answered.

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

mx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.