R
rocco
Hello,
I have a button in Form A that will open another form (Form B).
In Form B I have declared a class object:
Public WithEvents Calendario As Calendar
(it is calendar I have created with few feature needed by the application).
I have declared it as public hoping this will allow me to set two of its
properties through code in Form A by coding in Form A module:
DoCmd.OpenForm FormBname, acNormal 'and its module will create the
public Calendario object
Calendario.WhichControl = "contactData"
Calendario.WhichForm = Me.Name
But I get the error that the object doesn't exist.
Then I tried to solve the issue by creating a public calendar object in Form
A and setting its two properties in Form A module:
Public CalendarioST as Calendar
Private Sub Form_Load()
Dim i As Integer
Set CalendarioST = New Calendar
CalendarioST.WhichControl = "contactData"
CalendarioST.WhichForm = Me.Name
'then I open Form B
DoCmd.OpenForm FormBname, acNormal
Set CalendarioST=nothing
End sub
in Form B I tried this:
Private Calendario as Calendar
Private Sub Form_Load()
Dim i As Integer
Set Calendario = New Calendar
Calendario.WhichControl = CalendarioST.WhichControl
Calendario.WhichForm = CalendarioST.WhichForm
End sub
But still I get error! I need to create the object in Form B, but I have to
set two of its properties in Form A. I know I can go through public module
variables, but I would really know why my solutions shouldn't work! They both
seem reasonable to me. Obviously they are not and I would love to learn why.
Thanks!
Rocco
I have a button in Form A that will open another form (Form B).
In Form B I have declared a class object:
Public WithEvents Calendario As Calendar
(it is calendar I have created with few feature needed by the application).
I have declared it as public hoping this will allow me to set two of its
properties through code in Form A by coding in Form A module:
DoCmd.OpenForm FormBname, acNormal 'and its module will create the
public Calendario object
Calendario.WhichControl = "contactData"
Calendario.WhichForm = Me.Name
But I get the error that the object doesn't exist.
Then I tried to solve the issue by creating a public calendar object in Form
A and setting its two properties in Form A module:
Public CalendarioST as Calendar
Private Sub Form_Load()
Dim i As Integer
Set CalendarioST = New Calendar
CalendarioST.WhichControl = "contactData"
CalendarioST.WhichForm = Me.Name
'then I open Form B
DoCmd.OpenForm FormBname, acNormal
Set CalendarioST=nothing
End sub
in Form B I tried this:
Private Calendario as Calendar
Private Sub Form_Load()
Dim i As Integer
Set Calendario = New Calendar
Calendario.WhichControl = CalendarioST.WhichControl
Calendario.WhichForm = CalendarioST.WhichForm
End sub
But still I get error! I need to create the object in Form B, but I have to
set two of its properties in Form A. I know I can go through public module
variables, but I would really know why my solutions shouldn't work! They both
seem reasonable to me. Obviously they are not and I would love to learn why.
Thanks!
Rocco