Logic Problem - Prevent Original Code From Resuming After A Userform has been launched from it

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I hope someone is able to help me with a logic problem.

I have this piece of code associated to a button click of a user form. When a certain condition exists, the user is prompted for a yes or no answer.
Answering yes opens up another userform. The user then selects information from that userform. Once that information has been entered, that userform closes, and then takes the user back to the original code before the second userform was opened to resume.

My issue is this ... when the second userform opens, the original code resumes without the user being able to first process that userform.

Rich (BB code):
With ws_data
                'missing rental info?
                ar = WorksheetFunction.CountIf(.Range("A:A"), "act")
                pr = WorksheetFunction.CountIf(.Range("A:A"), "pass")
                If ar + pr > 0 Then 'missing data still exists
                    ui1 = MsgBox("There is still missing rental information associated with this date." _
                    & Chr(13) & "It is highly recommended that this information be submitted before proceeding." _
                    & Chr(13) & "Unwanted behaviour or results may result by continuing." _
                    & Chr(13) & "Would you like to process these rentals now?", _
                    vbYesNo + vbCritical, "MISSING INFORMATION : Rental Data")
                    If ui1 = vbYes Then
                        df1 = 1
                        test_mr.Show
                    End If
                End If
                
                'assess rental mergers
                duplicates (lmrg)
                MsgBox lmrg & " record(s) merged.", vbInformation

Green line is executed, test_mr initialization code is executed and the form is displayed populated. But instead of allowing the user to control that form, the original code resumes at the blue line. This cannot happen until the user has completed the necessary input associated with the 2nd userform.

What must I do to pause the original code until the second userform process has been completed?
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Re: Logic Problem - Prevent Original Code From Resuming After A Userform has been lunched from it

Hi,
In your forms properties settings check ShowModal = True


​Dave
 
Upvote 0
Re: Logic Problem - Prevent Original Code From Resuming After A Userform has been lunched from it

Hello Dave, thank you very much for your suggestion.
This appears to has indeed prevented the original code from being picked up after userform "test_mr" has been initiated.
However, I'm unable to get any controls to work in that form. There is a listbox for example, that when the user clicks on it, opens another userform. This isn't happening.

I do have a couple critical userforms open already when "test_mr" is opened. Could this be the problems?
 
Upvote 0
Re: Logic Problem - Prevent Original Code From Resuming After A Userform has been lunched from it

Hi,
My suggestion only answers your 1st query - Clearly, sounds like you have other issues with your project.
Suggest if possible, place copy of your workbook in public dropbox and post to the forum with explanation about the issues.
Perhaps I and possibly others will be able to give some guidance.

Dave
 
Upvote 0
Re: Logic Problem - Prevent Original Code From Resuming After A Userform has been lunched from it

Thanks Dave for the suggestion. The project is far too large and complex to expect anyone to leaf through it. The userform "test_mr" works fine except when it's open with ShowModal=True via this code.
I'll find another way. I should add, that only the listbox control doesn't trigger. The commandbuttons on that form do work.
 
Last edited:
Upvote 0
Re: Logic Problem - Prevent Original Code From Resuming After A Userform has been lunched from it

I think I have resolved the issue with a combination of Dave's advice, and changing the listbox click event to a listbox change event.
 
Upvote 0

Forum statistics

Threads
1,215,162
Messages
6,123,382
Members
449,097
Latest member
Jabe

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