I have a class which opens a form as dialog so I can use the form to send an email. Here is the class code:
Code:
' do some class code here
DoCmd.OpenForm "SendEmail", , , , , acDialog
' do more class code here AFTER the form is closed
The class has properties needed to send an email. These properties are set before executing the above code.
Currently, before executing the OpenForm command, I put these property values into TempVars, and the Form_Load event of the form takes the tempvars and uses them to load text boxes into the form.
The code above of course pauses after OpenForm, since I opened it as acDialog.
The form_Close event of the dialog form updates the TempVars with the new values from the text box, then when the form is closed, the calling class replaces the appropriate class member variables with the TempVar values and continues to run.
The entire purpose of the form is to let the user enter his/her own values for send-to, subject, body, etc.
Right now, this is working just fine, but seems overly complex.
Since I have already set most of the needed properties, I thought it would be so much easier to somehow send the class object into the form and update it directly, rather than having to use TempVars.
This is where I'm having my issue. I can define a form object as New Form_frmEmail, which will run the various events that get triggered when the form is opened, then tell the form to show itself when everything is loaded. This is where the problem occurs. If I open the form this way, it is not opened as dialog, so my calling code continues to run. This won't work.
If I open it as acDialog instead, I can't then send the class instance (Me) to the form, because code execution has stopped.
Is there any way to open the form NOT as dialog, but still have the calling code pause? If I recall from years past, VB6 would let you open a form hidden, then load its properties, then show it as dialog. But I don't think Access VBA can do this. Is there a work-around?