Halt Code and wait for input on PopUp form

JohanGduToit

Board Regular
Joined
Nov 12, 2021
Messages
89
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Greetings Experts,

I have code on a form named "MAIN" that opens a popup form "EDGARS_FILETYPE" which contains an option selection. I want the code on form "MAIN" to wait/stop execution and only continue once a selection was made (1 of 2 options selected) on the "EDGARS_FILETYPE" popup form. Once a selection was made on the "EDGARS_FILETYPE" popup form, the code on form "MAIN" should continue with a case selection where the case value is based on the option that was selected on the "EDGARS_FILETYPE" popup form.

At the moment the popup form opens; but the code on the MAIN form continues... my attempt below updates a text box on the MAIN form containing the selected option value from the popup form. The case statement is then based on the [Text130] value on the MAIN form.

The code is obviously not the way it should be done and is not working/has no effect.

Any input would be most appreciated!

VBA Code:
DoCmd.OpenForm "EDGARS_FILETYPE", , , stLinkCriteria
Select Case [Forms]![MAIN]![Text130].Value
     Case 1          'Edgars Kids
          Call FormatEdgars(fWorkingPath & fName, "Sales by store last week")         'Module15
     Case 2          'Edgars Adults
          MsgBox "FILE FORMATTING TO BE CONFIRMED", vbCritical, "WORK IN PROGRESS"
End Select
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, "EDG_RAW", fWorkingPath & fName, False
DoCmd.OpenQuery "010-APP_STAGING_10"
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Make "EDGARS_FILETYPE" modal.

Plus you appear to be referring to the main form for that value not the "EDGARS_FILETYPE"? , so would need to save the "EDGARS_FILETYPE" value somewhere to be able to refer to it after that form is closed.
 
Upvote 0
Make "EDGARS_FILETYPE" modal.

Plus you appear to be referring to the main form for that value not the "EDGARS_FILETYPE"? , so would need to save the "EDGARS_FILETYPE" value somewhere to be able to refer to it after that form is closed.
Greetings,

Thank you for replying to my enquiry.

The popup has been set to 'Modal'; but that did not help.

I just found the answer; must state "acDialog" when opening the popup form. Code halts until popup is closed.

Exactly what I wanted it to do... :-)

VBA Code:
DoCmd.OpenForm "EDGARS_FILETYPE", , , stLinkCriteria, , acDialog
 
Upvote 0
Make "EDGARS_FILETYPE" modal.

Plus you appear to be referring to the main form for that value not the "EDGARS_FILETYPE"? , so would need to save the "EDGARS_FILETYPE" value somewhere to be able to refer to it after that form is closed.
Also, yes, I am "saving" the selected option value on the popup form back to a Text box on the Main form before closing the popup form. The subsequent Case Statement then refer to the Text Box value on the Main form.

Thank you once again for your input.
 
Upvote 0
Greetings,

Thank you for replying to my enquiry.

The popup has been set to 'Modal'; but that did not help.

I just found the answer; must state "acDialog" when opening the popup form. Code halts until popup is closed.

Exactly what I wanted it to do... :)

VBA Code:
DoCmd.OpenForm "EDGARS_FILETYPE", , , stLinkCriteria, , acDialog
Yes, sorry, that is what I meant.

 
Upvote 0
Solution

Forum statistics

Threads
1,223,907
Messages
6,175,300
Members
452,633
Latest member
DougMo

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