I wonder if someone could help me please.
I need some vba code for use on an Excel userform to scroll through previous and next records by use of cmdPrev and cmdNext buttons respectively.
Thanks, Matt
I wonder if someone could help me please.
I need some vba code for use on an Excel userform to scroll through previous and next records by use of cmdPrev and cmdNext buttons respectively.
Thanks, Matt
You would need to give us the workbook that you have now, with the data, the form, and any code you have, otherwsie the brief is far to generic.
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
Isnt this the same as your other thread?
Anyway as stated its too generic. Where is the data from? From the excel spreadsheet? If so then just have a simple counter and the userform uses that counter in the reference of cells where:
[VBA]
private sub btnNext_click()
counter = counter + 1
textbox1 = cells(counter, 1)
end sub[/VBA]
Thanks for the reply grand, sorry, I haven't given enough information. The data is coming from an excel spreadsheet into frmRecord2, and is to be presented on this form, the < & > buttons will scroll previous and next results respectively. The data on the spreadsheet is a supplier database with name, address, tel bumber, fax number etc across the top (columns) and the database is filled downwards.Originally Posted by grandflavour
Here is an image of the form used to recall information from the spreadsheet, but to be honest i havent figured out a code yet to call the information to the textboxes but this should be fairly simple (fingers crossed). The < > cmdbuttons will then effectively scroll down the page going through each record one at a time.
Hope this helps, sorry for being vague. P.s. the copy button copies the information from the textboxes to the clipboard for use in other programs eg word. I already have the code to copy the data in the textboxes to the clipboard.
Cheers, Matt
Good Afternoon.
Excel does not have anything like a MoveNext or MovePrevious like Access does, so you have to do this manually.
You'll want to either add a Label to the Form, set it to Invisible, and store the current Row Number on it...
OR
Add a Module Level Variable of type Integer to store the Row Number.
Essentially, you are storing the current Record's Row Number. Then you can cycle through your data by incrementing and decrementing that Variable. Access the specific data using:
[VBA]
Worksheets("AddressData").Cells(intRow, 1).Value = txtName.Text
[/VBA]
Good luck.
Scott
You don't understand anything until you learn it more than one way. ~Marvin Minsky
I never teach my pupils; I only attempt to provide the conditions in which they can learn. - Albert Einstein