Modeless userform doesn't show if called twice from a modal userform (help!)

Oliver Dewar

Board Regular
Joined
Apr 17, 2011
Messages
201
Hi, first post and first attempt at in depth excel programming (so go easy on me!).

Here's a simplified version of what's going on for me.

I have a modal userform (modal1). If I click on a button the userform is hidden and a modeless userform (modeless1) is shown (modeless1.show False).

This modeless userform allows the user to search for and select a record on another sheet from which a lot of data will be used. Once the record has been selected the user presses a button on modeless1 and the data is copied to the original sheet, modeless1 is unloaded (modeless1.unload), the original sheet is selected and the original modal userform is shown (modal1.show) with the new info in it.

This works brilliantly... but it only works once. (and here's my problem).

If the user realises they selected the wrong record when using modeless1 and tries to go back to modeless1 to correct it by clicking on the same button on modal1... modal1 hides and then modeless1 does not appear (even though VBA shows that macros are still being run).

Is there a way to show modeless1 again? I tried hiding it instead of unloading it but it did exactly the same thing.

All help will be greatly appreciated.

Regards,

Oliver
 
Hi All,

Mike you've nailed it!

Let me declare for all the excel world that the way to call a modeless userform from a modal userform and go back and forward between the two as many times as you like is to create a specific instance and use something like:

Code:
Dim modelessForm as Object

Set modelessForm = New modeless1
modelessForm.Show

Using this method I've been able to create a more sophisticated and user-friendly way of performing a refedit control, using a second, modeless userform.

Thanks for all your help guys! :rofl:
 
Upvote 0

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,223,157
Messages
6,170,419
Members
452,325
Latest member
BlahQz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top