VBA for Previous and Forward button

excelconditional

New Member
Joined
Feb 21, 2017
Messages
6
[FONT=&quot]I am getting compile errors on the click command on the 'forward' and 'back buttons' on a form – can someone take a look?

My work book is on my one drive https://1drv.ms/u/s!Ag-WnkpUjiS9hy6MzsFk56w7ZJ8o

This is my form:



Previous button code:
[/FONT]


<code style="box-sizing: border-box; font-family: "Segoe UI", Arial, sans-serif; font-size: inherit; padding: 0px; color: inherit; background-color: transparent; border-radius: 0px; border: 0px; margin: 0px; vertical-align: top; -webkit-font-smoothing: antialiased; text-size-adjust: none;">Private Sub Back_Click()</code>
<code style="box-sizing: border-box; font-family: "Segoe UI", Arial, sans-serif; font-size: inherit; padding: 0px; color: inherit; background-color: transparent; border-radius: 0px; border: 0px; margin: 0px; vertical-align: top; -webkit-font-smoothing: antialiased; text-size-adjust: none;">'Prev
If ThisRow.Row > 2 Then
Set ThisRow = ThisRow.Offset(-1)
LoadData
End If
End Sub</code>
<code style="box-sizing: border-box; font-family: "Segoe UI", Arial, sans-serif; font-size: inherit; padding: 0px; color: inherit; background-color: transparent; border-radius: 0px; border: 0px; margin: 0px; vertical-align: top; -webkit-font-smoothing: antialiased; text-size-adjust: none;">
</code>


Forward button code:

<code style="box-sizing: border-box; font-family: "Segoe UI", Arial, sans-serif; font-size: inherit; padding: 0px; color: inherit; background-color: transparent; border-radius: 0px; border: 0px; margin: 0px; vertical-align: top; -webkit-font-smoothing: antialiased; text-size-adjust: none;">Private Sub Forward_Click()

If ThisRow.Row < Range("A" & Rows.Count).End(xlUp).Row Then
'Switch to the row and load the data

Set ThisRow = ThisRow.Offset(1)
LoadData
End If</code>


This code is not mine nor does it work for me. Can someone give me the exact code that will work on my form please?...
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
For me to help you I probable need more information.
This button is on a UserForm and the back button loads a row of data into some other control
and the two buttons either loads previous rows data or nexts rows data.

See for me to help I need some more information like this. And the back and formard buttons are command buttons I presume



Hi,

I would like the back button to go back to a previous submitted record and the forward button to go forward to the next submitted record (horizontal row on the spreadsheet).

Thanks
 
Upvote 0
For me to help you I probable need more information.
This button is on a UserForm and the back button loads a row of data into some other control
and the two buttons either loads previous rows data or nexts rows data.

See for me to help I need some more information like this. And the back and formard buttons are command buttons I presume

Here is the screen shot of the form

https://1drv.ms/i/s!Ag-WnkpUjiS9hy9xm6wZCGzLsBxL

And here is the excel spreadsheet again with form - please take a look: https://1drv.ms/u/s!Ag-WnkpUjiS9hy6MzsFk56w7ZJ8o

The 'Add record button' you can see in the form, sends the data selected to the spreadsheet with an ID number and timestamp to its related column.

I want the 'previous' and 'next button' (both command buttons) to be able to go back and forth and ammend / overwrite previously submitted records (which appear in the rows on the spreadsheet) including overwriting the original time stamp.
 
Upvote 0
Thanks for providing all those links to your data. I never click on links.
Since your not willing to provide details in words then I'm not able to help you.
Maybe someone else at Mr. Excel will be able to help you.

Here is the screen shot of the form

https://1drv.ms/i/s!Ag-WnkpUjiS9hy9xm6wZCGzLsBxL

And here is the excel spreadsheet again with form - please take a look: https://1drv.ms/u/s!Ag-WnkpUjiS9hy6MzsFk56w7ZJ8o

The 'Add record button' you can see in the form, sends the data selected to the spreadsheet with an ID number and timestamp to its related column.

I want the 'previous' and 'next button' (both command buttons) to be able to go back and forth and ammend / overwrite previously submitted records (which appear in the rows on the spreadsheet) including overwriting the original time stamp.
 
Upvote 0
Thanks for providing all those links to your data. I never click on links.
Since your not willing to provide details in words then I'm not able to help you.
Maybe someone else at Mr. Excel will be able to help you.

I have provided details in words to the best of my ability.

Don't worry about it- I'll take my query back to the professionals at Excel Forum where people admit upfront when they can't help you :)

Ciao!
 
Upvote 0

Forum statistics

Threads
1,214,826
Messages
6,121,794
Members
449,048
Latest member
greyangel23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top