Actually I have two questions. The first is how to get a variable to stay alive long enough to use it in another Sub. For example, if I set a variable in some code and then that code opens a popup form, then I click a button on the popup, and that code needs to be able to reference the variable assigned in the code that opened the popup.
The other question, which in this case would eliminate the need for the global variable, is: why doesn't the rest of the code run after the popup is closed. For example: I have these records that reference photos that appear on the form. If the user clicks a button they can delete the photo from the list so it no longer appears. When they do this, I want ask them if they also want to delete the file itself or not - so I open the popup that has two buttons on it - one for deleting the file file and one for just removing it from the list. So if they click on the 'Dlete File" button that code deletes the file. Then I want the rest of the original code to run, which deletes the record, but it never goes back. Is it possible to get it to resume? Below is the code I have now. The commands after the OpenForm command never get executed.
Sub cmdDeleteRecord_Click()
strPopUp = "PopUpDeleteFile"
DoCmd.OpenForm strPopUp
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End Sub
The other question, which in this case would eliminate the need for the global variable, is: why doesn't the rest of the code run after the popup is closed. For example: I have these records that reference photos that appear on the form. If the user clicks a button they can delete the photo from the list so it no longer appears. When they do this, I want ask them if they also want to delete the file itself or not - so I open the popup that has two buttons on it - one for deleting the file file and one for just removing it from the list. So if they click on the 'Dlete File" button that code deletes the file. Then I want the rest of the original code to run, which deletes the record, but it never goes back. Is it possible to get it to resume? Below is the code I have now. The commands after the OpenForm command never get executed.
Sub cmdDeleteRecord_Click()
strPopUp = "PopUpDeleteFile"
DoCmd.OpenForm strPopUp
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End Sub