Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What's the best way to pass variables among forms?

Status
Not open for further replies.

shauntwo

Technical User
Jul 9, 2002
64
0
0
US
Hi,

I have a "switchboard" form that opens up several accounts in a personal finance database I'm trying to write. Whenever I click on an account label in the switchboard, I have a dummy transaction form that comes up, for which I'd like to display a recordset of all transactions based upon the account label clicked in the switchboard (if you're familiar with MS Money, this is the same principle I'm guessing). Trouble is, I don't know how to communicate the account label clicked in the switchboard with the dummy transaction form, so that it knows what account records to query. What's the best programmatic way to do this? Can the modules tab of the Access database be used to pass variables among object modules?

Thanks for your help.
 
Well, there are any number of ways. It all depends on what you're doing. You can use a form's OpenArgs property, you can set a field on the calling form, you can pass a value when you call a function or sub, you can pass a where clause when you open a form, you can set a global variable, or you can act from the code that does the opening.

What is the code you're using now, and what exactly are you trying to accomplish?

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.
 
Jeremy,

Well, I don't have code set up yet in the Switchboard form, but for instance, if I have clicked on "Checking" (a label right now), I will need something in the On_Click event to assign the label name "Checking" to a variable. Right now, the On_Click opens my dummy transaction form. Once I've entered a transaction, which is bound to a Transactions table, I will need the value of the variable from the Switchboard (in this case, "Checking") to be inserted into a field in the Transactions table, with something like Me![Account] = "Checking".

You might ask, "Why not just have a bound combo box in the form to assign the account?" Well, I'd just like to learn how to do it this way, for the sake of learning. I can't give you the code I actually have, because it's at home, but let me know if this doesn't help you advise.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top