Hi all,
I've been trying to use some public variables in my DB but they seem to "disappear" quite easily and I was wondering if anyone was aware of this problem
(2003)
' Vars are defined when the database opened:
' Public Vars for the Valuations form
Public Task_Subform As Form
Public Task_Subform_Control As Control
Public Val_Form As Form
********************* then..
Public Function RAV_SetVars()
'These Vars are set either at Form_Current if there are
'records in the subform or when the first record is added
' to the subform
' Parent Form
Set Val_Form = Form_Add_Edit_Valuations
' Continous Subform
Set Task_Subform_Control = Val_Form.AllTasks_Subform_SF
Set Task_Subform = Val_Form.AllTasks_Subform_SF.Form
The idea being that I don't have to pass form and subform variables in and out of other functions and can just use the Shortened Names to refer to them in code.
But when I attempt to use these vars in other modules they are set to "nothing"( but not always). For example:
Function Do_Debug (ParentValuation As Form)
'This works fine…
ParentValuation.DebugText = ParentValuation.DebugText & vbNewLine & "Val_Finish_Current_Task"
'This barfs sometimes– error 91 – object variable or with block
' variable not set
Val_Form.DebugText = Val_Form.DebugText & vbNewLine & "Val_Finish_Current_Task"
Also I've noticed that my Debug_On public varaible, which is set in a "main" form that never closes is also being unset.
What's going on?
I've been trying to use some public variables in my DB but they seem to "disappear" quite easily and I was wondering if anyone was aware of this problem
(2003)
' Vars are defined when the database opened:
' Public Vars for the Valuations form
Public Task_Subform As Form
Public Task_Subform_Control As Control
Public Val_Form As Form
********************* then..
Public Function RAV_SetVars()
'These Vars are set either at Form_Current if there are
'records in the subform or when the first record is added
' to the subform
' Parent Form
Set Val_Form = Form_Add_Edit_Valuations
' Continous Subform
Set Task_Subform_Control = Val_Form.AllTasks_Subform_SF
Set Task_Subform = Val_Form.AllTasks_Subform_SF.Form
The idea being that I don't have to pass form and subform variables in and out of other functions and can just use the Shortened Names to refer to them in code.
But when I attempt to use these vars in other modules they are set to "nothing"( but not always). For example:
Function Do_Debug (ParentValuation As Form)
'This works fine…
ParentValuation.DebugText = ParentValuation.DebugText & vbNewLine & "Val_Finish_Current_Task"
'This barfs sometimes– error 91 – object variable or with block
' variable not set
Val_Form.DebugText = Val_Form.DebugText & vbNewLine & "Val_Finish_Current_Task"
Also I've noticed that my Debug_On public varaible, which is set in a "main" form that never closes is also being unset.
What's going on?