Having a VBA menu return after use

Having a VBA menu return after use

Anonymous
Not applicable
1,307 Views
3 Replies
Message 1 of 4

Having a VBA menu return after use

Anonymous
Not applicable

I want some advice on how to have a menu created in vba return after its major function has been run.

As shown below, I have a menu I created in vba and when the create button is pressed, the user defines at what point in the drawing that the resulting second figure should be placed.

menu.PNGMenu I start and want to return to

 

Result_of_menu.PNGResult of hitting the create button

At the end of this, I would like to return to the original menu as I am forced to hide it once the button is pressed in order for the user to place the object down.

 hide.PNG

However, I cannot, as of now, seem to just show the menu at the end of the button-click function because I would like to have the object placed and shown as above before the user places a different object. show.PNG

 

Can I have some help?

0 Likes
Accepted solutions (1)
1,308 Views
3 Replies
Replies (3)
Message 2 of 4

Ed__Jobe
Mentor
Mentor
Accepted solution

Can you set the forms ShowModal property to true? Then you won't have to hide it. You'll need to add a close button to cancel the form.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 3 of 4

Anonymous
Not applicable

Hello again,

Ed's idea seemed to work and I did some research on what ShowModal meant here and even though it is for excel, it still helped a lot.

https://wellsr.com/vba/2016/excel/showmodal-vba-vbmodal-and-vbmodeless/

 

Here is how I edited the code for what I wanted it to do:

In a menu above that opens this menu, I ran the following code.

above menu code.png

That now shows this edited menu

menu2.png

The code is run as follows below: if the repeat button is clicked, it remains modeless

if the finish button is clicked, it hides the menu

code result.png

 

 

0 Likes
Message 4 of 4

Ed__Jobe
Mentor
Mentor

When you finish with the form, you don't want to simply hide it as it will still be in memory. Follow up your code with:

Unload Me

 

Either that or create a Close button with its only code is Unload Me. That way a user can also, leave without adding entities. i.e. cancelling the dialog.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature