Products A-Z All Services Can't find what you're looking for? Chat Live!
Products A-Z Can't find what you're looking for? Chat Live!
Can't find what you're looking for? Chat Live!
I am creating a macro for entering a new individual consitutent. Unfortunately the only reference I have found so far to Forms in the RE VBA esentials guide is on page 98, where it indicates that "VBA provides full-featured forms design support", where I "can design a custom data entry form". It does not however, explain how to do this. After much reseach, trial, and error I have found that I must start the macro with the following code in the module named "User_Macros":
Public Sub AddNewMember() Load frmNewMembers frmNewMembers.ShowEnd Sub
Where "AddNewMember" is the name of the macro. Now my macro is being terminated as follows:
Private Sub cmdExit_Click() moCodeTablesServer.Closedown Set moCodeTablesServer = Nothing End End Sub
This is taking place in the form, not in the original User_Macro module. The "Closedown" and "Nothing" lines are to shut down the Code Tables Server that I am using to load a combo box -- it took me quite awhile to figure out how to do this also, especially since there was an error in the sample code. But I am wondering if I am going to end up with any memory leaks from not unloading the form? Is this done automatically as part of the "End" statement? I cannot figure out how to return to the original code and unload the form.
Jim,
You should not use the key word 'End'. This is really quite obsolete and kills everything.
In the cmdExit_Click() method you should hide the form. i.e. me.hide or you could put Unload(me).
If the form is modal then the code will pass back to the User_Macro module and you could put the Unload(frmNewMembers) there instead but only after you have hidden the form.
If you need any more help then do not hesitate to ask.
David
Yes, either method works. However I get a runtime error if I used Unload(object). When I write the line as
Unload Me
or
Unload frmNewMembers
then everything works fine.
Thank you for the advise. I am sure the I will be back for more. I have had a very little programming experience. Building reports in Crystal Reports was not too bad. But there is a lack of documentation for VBA programming, and I need good documentation.
Thanks again.
Yes you are correct. It is without the parenthesis in VBA/VB6. I wrote my answer a bit too late at night and got confused. Pleased it is working now.