# Halt Code and wait for input on PopUp form



## JohanGduToit (Dec 6, 2022)

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!


```
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"
```


----------



## welshgasman (Dec 6, 2022)

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.


----------



## JohanGduToit (Dec 6, 2022)

welshgasman said:


> 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... 


```
DoCmd.OpenForm "EDGARS_FILETYPE", , , stLinkCriteria, , acDialog
```


----------



## JohanGduToit (Dec 6, 2022)

welshgasman said:


> 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.


----------



## welshgasman (Dec 6, 2022)

JohanGduToit said:


> Greetings,
> 
> Thank you for replying to my enquiry.
> 
> ...


Yes, sorry, that is what I meant.






						Pop-up, Modal, or Dialog Forms
					

This article is an excerpt, reprinted with permission, from the book " Professional Access 2013 Programming ."    Pop-up, Modal, or Dialog F...




					thedbguy.blogspot.com


----------

