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
KDWW
Avatar of lludden
lludden
Flag of United States of America image

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.
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of KDWW
KDWW
Flag of United States of America image

ASKER

Interesting!  I'll need to experiment but looks promising.
Avatar of IrogSinta
IrogSinta
Flag of United States of America image

I've included a snippet.
What snippet?
:-)
Avatar of Hamed Nasr
Hamed Nasr
Flag of Oman image

"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
Avatar of KDWW
KDWW
Flag of United States of America image

ASKER

Just what I needed!  Thank you capricorn1!!
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo