I’m using Access 2010 and would like to have a user click a button in Form1 called “Save As” that initiates VBA code, and before the code is done running, have it pause, open up Form2 (where the user enters a “Save As” title, and clicks Save), and then have the code continue running in Form1 using the string entered in Form2 as a variable.
I’m just not sure how to “pause” my code in Form1 as it waits for the user to make an input. Any ideas on how to approach this?
From
Form1, openForm2in dialog mode.Form1code will wait onForm2.Add a “done” button to
Form2, and add a procedure to its click event whichreopenshides the form by setting itsForm2hidden.Visibleproperty to False. Making it hidden breaks it out of dialog mode. So after the user inputs her value, she can click “done”, flow control will resume inForm1and can read the input value from the control on the now-hiddenForm2.With this approach,
Form2need not know anything aboutForm1. SoForm2can be used to gather input for any arbitrary form … or other code.So assuming
Form1has a command button namedcmdSaveAs, use something like this as its click event procedure.