Form & Sub Form

Parra

Well-known Member
Joined
Feb 21, 2002
Messages
752
I have a form with Sub Forms and I would like to be prompted if I would like to to "Save" the record, before I can advance to the next one. That is if I have made changes to the record.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Use the SubForm's BeforeUpdate event:
Code:
Your_Form_BeforeUpdate(Cancel as Integer)
If MsgBox ("Would you like to Save these Changes?", vbYesNo)=vbNo Then
  Me.Undo
  Cancel=True
End If
End Sub

and then, because no code has been written behind vbYes, the Record will be Saved and lose focus as normal.
 
Upvote 0
Hi Dugantrain, I forgot to mention that there is one main form and 3 subforms. I would like the message to pop up for any changes in any of the 3 forms, if any changes were made.

Where should I enter the code, you said the sub form, but there are 3 of them.

Thanks, Parra
 
Upvote 0
OK, Great I added the code to the main form and the 3 sub forms and I think I got it to do what I wanted.

Thanks for all your help.

Parra
 
Upvote 0

Forum statistics

Threads
1,221,621
Messages
6,160,879
Members
451,675
Latest member
Parlapalli

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