Home > Excel Tutorial > Next – Previous Buttons on Userform

Next – Previous Buttons on Userform

 

User can view the records with previous control and next control buttons easily .Also in this form,

If you click “cmdfirst” button, the form goes to the first record.Or If you click “cmdlast” button, the form goes to the last record.While viewing records on listbox, you can see the order of records in “textBox6”.

Nature picture was used as background of the this userform.

Codes of Previous Button :
If ListBox1.ListIndex = 0 Then
MsgBox “First Record”, vbCritical
Exit Sub
Else
TextBox6 = TextBox6 – 1
With Me.ListBox1
.ListIndex = .ListIndex – 1
End With
End If

Codes of Next Button :
If ListBox1.ListIndex = ListBox1.ListCount – 1 Then
MsgBox “Last Record”, vbCritical
Exit Sub
Else
TextBox6 = TextBox6 + 1
With Me.ListBox1
.ListIndex = .ListIndex + 1
End With
End If

Template Download

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: