Avatar of KDWW
KDWWFlag for United States of America asked on

Call variable from one form to another

I'm working an application that is now requiring a little VBA.  I've been away from it too long to remember the details.  I need to use a variable created in one form (through the use of a command button) and recall the same variable in another form that will then insert it into a table.  I've included a snippet.  Very simple at this stage but I'm facin a brain freeze.
Microsoft Access

Avatar of undefined
Last Comment

8/22/2022 - Mon

You can stick the variable in a module, then it will be globally visible within the application.

You can also define it as a global within a form and then access it from other forms.

There are a few other ways too, but those are the easiest.
Rey Obrero (Capricorn1)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Interesting!  I'll need to experiment but looks promising.

I've included a snippet.
What snippet?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Hamed Nasr

"form that will then insert it into a table"
If interested in the value to insert in a table, then you can pass it as OpenArgs in the OpenForm.

DoCmd.OpenForm "otherForm", acNormal, , , , , "1234"

You can use the value in otherForm:
tableValue = Me.OpenArgs

Just what I needed!  Thank you capricorn1!!