Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Force User to Save Record on Master Form 1

Status
Not open for further replies.

fishtek

Technical User
Aug 21, 2002
56
US
Hello:
I have a master form with several buttons that open child forms. The master form passes certain record info to the child forms provided the record has been saved. Problem is if a user forgets to save a record on the master form, they get an error message when attempting to save the record on the child form. How can I force the user to save the record on the master form (if he forgets) before opening the child forms.
Thanks for any help.
 
When button is clicked, check for me.dirty = True. If True, DoCmd for saving the record.

[purple]If we knew what it was we were doing, it would not be called
research [blue]database development[/blue], would it? [tab]-- Albert Einstein[/purple]​
 
Thanks for your prompt response:
Would you be referring to the OnClick event for the child form button? Or something on the master form? I'm still confused on where your suggestion should occur. Thanks and sorry for the confusion.
 
You want the data saved before you get to the child form. So for the OnClick event of the button that is pressed after data has been entered (presumably this is the button for 'open child form' or 'enter this info'), check for the form property Dirty. If false, on to the button's next function; if true, insert the save command.

Pasted is some code that addresses something like this ... Needs some cleaning and remove the 'remark' marks!

Code:
Private Sub btnNextThing_Click()
On Error GoTo ErrHandle
'    '' MyTips if data changed on form, confirm save, then close.
'    If Me.Form.Dirty Then
'        Dim Response As String
'        Response = MsgBox("Save your changes?", vbYesNoCancel, "Record for Contact")
      '      Response = MsgBox(strMsg, vbOKCancel, "Record for Component")
      '      If Response = vbOK Then Me.Form.Dirty = False
      '      If Response = vbCancel Then Me.Undo
'        Select Case Response
'        Case vbCancel:  Exit Sub
'        Case vbNo:      Me.Undo
'        Case vbYes
'            Me!DateChange = Date
'            If Me.Dirty Then DoCmd.RunCommand acCmdSaveRecord
'        End Select
'    End If

[purple]If we knew what it was we were doing, it would not be called
research [blue]database development[/blue], would it? [tab]-- Albert Einstein[/purple]​
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top