View Full Version : Saving Subforms


talic
10-31-2000, 05:26 AM
What's the best way to alert the user to save changes made to the record within a form that contains 7 subforms.
Here is the procedure i use to save changes on the main form , but can't seem to make it work for subforms.

This routine accepts a form name and saves the curent changes.
Public Sub FormSaveRecord(frmIn As Form)
On Error GoTo PROC_ERR
frmIn.Dirty = False

PROC_EXIT:
Exit Sub

PROC_ERR:
MsgBox "Error: " & Err.Number & ". " & Err.Description, , _
"FormSaveRecord"
Resume PROC_EXIT

End Sub

I call the above procedure from within the form.

If frm.Dirty Then ' Has user made unsaved changes?
'Call fOSUserName ' Get login name of current user
Dim msgChanged As CMsgBox
Set msgChanged = New CMsgBox
With msgChanged
.Title = gcstrStudyName
.Icon = icoQuestion
.Buttons = btnYesNoCancel
.DefaultButton = dfButton1
.Modal = mbApplicationModal
.Message = "Save changes to this record?"
End With
msgChanged.Show
Select Case msgChanged.Response
Case mbReturnCancel ' Do nothing
GoTo Exit_Routine
Case mbReturnYes ' Save changes
txtChangeDate = Now() ' Add date
txtChangeUser = fOSUserName ' Add user name
' Currently on new record?
fNewRecord = FormOnNewRecord(frm)
Call FormSaveRecord(frm)


how can i use the existing code for saving changes in the subforms.
Right now Access saves subforms automatically.
I don't want that i want the users to be aware of any changes they make.


THANK YOU I APPRECIATE IT.