Keep object in memory while is form is open (Post in Stack Overflow)

OK, what is the purpose of the post? You got some discussions and suggestions. Why did you post this here? Did something not work?
 
OK, what is the purpose of the post? You got some discussions and suggestions. Why did you post this here? Did something not work?
Because if you aren't getting answers in one forum it is good to ask in others but cross-posting is not a good practice. It is always suggested to just post the link so multiple people do not give the same answers.
 
You have seriously overcomplicated this and besides userforms are different from Access forms.
How did I over complicate it? I called an object and initialized some properties. Then later in a second click event I tried to use those properties and the object is no longer in memory. If it is too complicated, tell me how you would have done it differently. I am here to learn.
 
So lets simplify to the relevant code

1. You have a custom class and instantiate it in the form click event
Code:
Public this_renewal As Renewal

Private Sub cmdMA_Click()
      Set this_renewal = Factory.CreateRenewal(cMA)
      'other code here
End Sub

we know that the class instantiates without problem. But when you try to reference it again you get an object variable not set.

2. We then try to use the instantiated object later but you get that it is not set.
Code:
Private Sub cmdImport_Click()
    strTableName = this_renewal.Table
End Sub

Before we start chasing our tails. "This_renewal" is declared and used in the same form module, and you are confident the below line is causing the error?
Code:
strTableName = this_renewal.Table
 
You confident this is not your true problem
Code:
 Call FixExcelFile

How about putting at the top of the method
Code:
msgbox this_renewal is nothing
msgbox this_renewal.table is nothing
 

Users who are viewing this thread

Back
Top Bottom