PDA

View Full Version : Next Record / Previous Record



Delta
07-02-2009, 11:10 AM
Hello,

I would like to have a function on my User Form which enables me to click on a button for the next record, and similarly for the previous record. In that way, someone could scroll through each record one by one.

Let me elaborate a little. The records are stored on a spreadsheet. When you click on Next Record, it will take the information from the spreadsheet and populate the User Form.

Please could someone help me find a solution to this?

Thank you very much.
Delta

lucas
07-02-2009, 11:48 AM
Show us your userform so we don't have to create it and guess about how you are doing things......

attach your file by going to post reply at the bottom left of the last post and after adding your message scroll down and look for the button that says "manage attachments"

Bob Phillips
07-02-2009, 12:42 PM
Here is an example

klutz
07-02-2009, 08:22 PM
XLD, you da MAN...

I was wondering, in the user form records, can you send out to print the records shown instead of the complete data set? This is something that I could use and work with. :-)

Bob Phillips
07-03-2009, 01:00 AM
Do you mean print the form, or just print parts of each dataset?

klutz
07-03-2009, 07:13 AM
Do you mean print the form, or just print parts of each dataset?

I guess just printing the data that appears on the userform. I used your vba code and adapted to mine and also added the show print dialog so that i may print. It does print the whole data, not just what shows on the userform. How can this be accomplished?

Bob Phillips
07-03-2009, 07:24 AM
Forms have a PrintForm method, so you can simply do



Userform1.PrintForm


althougn this does show the form controls as well.

Delta
07-03-2009, 09:04 AM
xld, thank you for your example. That is very helpful.

I have attached a copy of my spreadsheet. I will try to edit the code for my User Form and see how I get on.

Thanks!
Delta

Bob Phillips
07-03-2009, 09:24 AM
Post back if you get stuck.

Delta
07-03-2009, 10:28 AM
The problem I'm having is, I want the last record to show when I open the User Form. If this is implemented, the Next Record and Previous Record buttons should work - is that correct?

Bob Phillips
07-03-2009, 10:39 AM
My code showed the First record, so just change this part to Last record. Next won't do anything on the last record.

Delta
08-15-2009, 01:57 AM
I am having trouble implementing this into my own User Form. I have tried to follow your example, xld, but am probably doing something wrong. Please could someone help me?

Thank you.
Delta

Aussiebear
08-15-2009, 04:34 AM
Where Bob's code has the following ,
Private Sub UserForm_Activate()
With Worksheets("Data")

mcMaxRecords = .Cells(.Rows.Count, "A").End(xlUp).Row - 1
End With

Call cmdFirst_Click
End Sub


Change the line Call cmdFirst_Click to Call cmdLast_Click