FoxProProgrammer
Programmer
My form has a subform. The user can click in a field on the subform and change the contents. The following events run.
The Enter event stores the initial value of the field.
The AfterUpdate event checks if the user changed the contents of the field.
The code works with the following exception. The value of chgSaved is not available to procedures in the main form's module. I use chgSaved to determine whether to display a MsgBox when the user closes the Form. If unsaved changes exist, the message warns them that they will lose their changes unless they click Yes to continue editing.
The variable chgSaved is declared below the Option Compare Database statement in the main form's module. My recollection is that this is the area where public (global) variables are defined.
The Access Help says:
Variables declared using the Public statement are available to all procedures in all modules in all applications unless Option Private Module is in effect;
Option Private Module is not in effect. Why is the value of chgSaved not global? It is global for all procedures in the Main form's module. It just doesn't work on the subform.
Thanks!
dz
The Enter event stores the initial value of the field.
The AfterUpdate event checks if the user changed the contents of the field.
The code works with the following exception. The value of chgSaved is not available to procedures in the main form's module. I use chgSaved to determine whether to display a MsgBox when the user closes the Form. If unsaved changes exist, the message warns them that they will lose their changes unless they click Yes to continue editing.
Code:
Private Sub PartSN_Enter()
initSN = PartSN.Value
End Sub
Private Sub PartSN_AfterUpdate()
If initSN <> PartSN.Value Then
Forms!frm_EditJob.btn_save.Enabled = True
chgSaved = False
End If
End Sub
The variable chgSaved is declared below the Option Compare Database statement in the main form's module. My recollection is that this is the area where public (global) variables are defined.
Code:
Public chgSaved As Boolean
The Access Help says:
Variables declared using the Public statement are available to all procedures in all modules in all applications unless Option Private Module is in effect;
Option Private Module is not in effect. Why is the value of chgSaved not global? It is global for all procedures in the Main form's module. It just doesn't work on the subform.
Thanks!
dz