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

want next button hidden if no other record

Status
Not open for further replies.

JSD

Technical User
Jan 18, 2002
189
US
Hello

I was wondering if I could ask how to hide a next button on a form if the qry driving the form pulls only one record.
Any help would be interesting and helpful.

THanks

Jeremy
 
Morning again Jeremy

Are you talking about a button that you have created or the navigation / record selectors at the bottom of your form.

If it is the first

you could use dcount and this will give you the number of records in your data source

x = dcount("fieldname","tblname")
if x = 1 then me.cmdbuttonNext.visible = false


other wise you could set record navigation to no and the selectors at the bottom would not be visible

hope this helps

regards

jo
 
Hello

Thanks for the advice. I tried putting the dcount expression in the OnActivate event of the form that has the navigation button, but it did not show a result. I would imagine I put it in the wrong place. Any further suggestions?

THanks

Jeremy
 
Jeremy,

I've got "First", "Next", "Previous", and "Last" record buttons on a form that I disable if they don't apply to the current recordset.

The following is from the "On Current" event of the form.
My buttons are FirstRecord, NextRecord, PreviousRecord, and LastRecord. You should be able to use it for just the NextRecord button if thats all you need.


Private Sub Form_Current()

Dim recClone As Recordset

Set recClone = Me.RecordsetClone()

If recClone.RecordCount = 0 Then
FirstRecord.Enabled = False
NextRecord.Enabled = False
PreviousRecord.Enabled = False
LastRecord.Enabled = False
Else

FirstRecord.Enabled = True
LastRecord.Enabled = True

recClone.Bookmark = Me.Bookmark

recClone.MovePrevious
PreviousRecord.Enabled = Not (recClone.BOF)
recClone.MoveNext

recClone.MoveNext
NextRecord.Enabled = Not (recClone.EOF)
recClone.MovePrevious
End If

recClone.Close

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top