Pass a value back to vba when form is closed (1 Viewer)

AndrewS

Registered User.
Local time
Today, 13:25
Joined
Feb 21, 2017
Messages
30
I wonder if this is possible, and if so how.

Background: I've just been testing a process for uploading a file and checking for duplicates. It presents a series of forms for the user to check and confirm before proceeding.
What I've found in testing is that it's easy to miss something and I need to be able to offer the user the opportunity to go back to a previous form, or cancel the process.

My vba at present goes something like this:
Prepare data & present form1 to user
User closes form1
Prepare data & present form2 to user
User closes form2
Prepare data & present form3 to user

Using "continue" "restart" buttons on the forms, I'd like it to run something like this:

form1:
Prepare data & present form1 to user
User closes form1
form2:
Prepare data & present form2 to user
If form2 = "re-do form1" goto form1
Prepare data & present form3 to user
If form3 = "re-do form1" goto form1 else if form3 = "re-do form2" goto form 2

But my brain needs a nudge as to how to return the button clicked to the code, to allow it either to proceed or repeat a section.

I'm sure it's possible, but my mind's a blank. :banghead:
 

Ranman256

Well-known member
Local time
Today, 08:25
Joined
Apr 9, 2015
Messages
4,337
declare a global variable in a module (not in a form)
public gvMyVar

then before the form closes , save it
gvMyVar = txtBox
gvMyVar = me.name

then all forms and modules can see this value
 

Users who are viewing this thread

Top Bottom