Custom navigation button (1 Viewer)

Dazza666

Registered User.
Local time
Today, 02:23
Joined
Aug 13, 2008
Messages
56
Hi,

I would like to disable my 'next record' button if it is the last record in the set, this is to avoid the access error message 'can't go to specified record' i'd also like to do the same with my 'previous record' button on the first record in the set.

i'd probably place this in the onCurrent event.

My psuedo code would be

if me.currentRecord = last then
me.btnNext.enabled = false
else
me.btnNext.enabled = true
end if


Is this possible???

thanks
 
Are you using a bound or unbound form to display the records?

If you are using an ubound form with a recordset they suggest you try testing for Rs.BOF and Rs.EOF on the next/previous button clicks and disable/enable accordingly.

Eg:

Code:
Sub CmdNext_Click()
   If Rs.EOF Then
      'Set the focus elsewhere
      Me.CmdNext.Enabled = False
      Me.CmdLast.Enabled True
      Me.CmdBack.Enabled = True
      Me.CmdFirst.Enabled = True
   Else
     .....
   End If

End Sub
 
Are you using a bound or unbound form to display the records?

If you are using an ubound form with a recordset they suggest you try testing for Rs.BOF and Rs.EOF on the next/previous button clicks and disable/enable accordingly.

Eg:

Code:
Sub CmdNext_Click()
   If Rs.EOF Then
      'Set the focus elsewhere
      Me.CmdNext.Enabled = False
      Me.CmdLast.Enabled True
      Me.CmdBack.Enabled = True
      Me.CmdFirst.Enabled = True
   Else
     .....
   End If
 
End Sub

cheers m8,

the form is bound though so i'm not sure where this leaves me?

i'll try the code though! thanks again
 
If using a bould form why are you not using the forms navigation buttons?
 
If using a bould form why are you not using the forms navigation buttons?

I want to leverage more control over the use of the forms so I would like to disable the navigation controls on all forms
 
Another way which does not look as flash as Leigh's but is very simple to work with is

Put two unbound texboxes on your form and in one put =[CurrentRecord] and in the other =Count(*)

=CurrentRecord will display which record your are on irrespective of sorts. filters and =Count(*) shows all the records.

Because you have the count for which record you are on as well as the total number of records you can easlity do just about anything including the Record 10 of 187 etc

I use this a lot in telemarketing data bases I make. For example the =Count(*) box - the =[Current Record] box is the number of records left an at the appropriate number things get organised to bring more names into the main table. The list is endless and all simple stuff.

Edit: The disadvantage of that system compared to Leigh's is being unbale to scroll through record, it will be one at a time for each click on a GoToNextRecord or GoToPrevious

.
 
Another way which does not look as flash as Leigh's but is very simple to work with is

Put two unbound texboxes on your form and in one put =[CurrentRecord] and in the other =Count(*)

=CurrentRecord will display which record your are on irrespective of sorts. filters and =Count(*) shows all the records.

Because you have the count for which record you are on as well as the total number of records you can easlity do just about anything including the Record 10 of 187 etc

I use this a lot in telemarketing data bases I make. For example the =Count(*) box - the =[Current Record] box is the number of records left an at the appropriate number things get organised to bring more names into the main table. The list is endless and all simple stuff.

Edit: The disadvantage of that system compared to Leigh's is being unbale to scroll through record, it will be one at a time for each click on a GoToNextRecord or GoToPrevious

.

Thats really clever, i'll keep this in mind thanks
 
I should possibly point out that the nav buttons I demo are just that - a demonstration of the concept that I knocked up for a question a while back (I haven't even listed it on my site thus far - as Stephen Lebans has a near identical implementation on his site).

I don't use navigation buttons often -and when I do I use the Access form default ones.
I prefer to keep my forms' sources limited to, ideally, just one record at a time (for efficiency and control reasons).
Obviously that doesn't apply to lists (continuous forms/datasheets).
 

Users who are viewing this thread

Back
Top Bottom