Forms VBA Tabs

johnbird1988

Board Regular
Joined
Oct 6, 2009
Messages
199
Hello
I have a form with 5 different tabs. On one of the tabs called “Employee” I have a sub form. When I click on this tab I know that access will automatically save any change because it moves out of focus. Is there some VBA code I can attached to the “Employee” tab that will respond to a yes, no box? I would like the Yes to continue to the “Employees” tab and the no to return to the current tab. I have the below bit of code at the moment.
Private Sub Employee_Click()
If MsgBox("All changes will be saved. Would you like to continue?", vbYesNo) = vbYes Then
End If
End Sub
End Sub
Thank you
John
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Just use the subform's Before Update event. If you cancel, it should stay where it is.

Rich (BB code):
Private Sub Form_BeforeUpdate(Cancel As Integer)
    If Msgbox("All changes will be saved.  Would you like to continue?", vbQuestion + vbYesNo, "Please Confirm...") = vbNo Then
        Cancel = True
   End If
End Sub

Oh, and by the way - you can't use the tab's click event or the tab page's click event. They are useless. You have to use the tab control's ON CHANGE event to do anything associated with someone moving to another tab. We don't in this part because we are working with the Before Update event which should cancel the move if it is canceled.
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,875
Members
452,949
Latest member
Dupuhini

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