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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Data to field on next form.

Status
Not open for further replies.

bblekfeld

Programmer
Mar 9, 2004
49
US
I'd like to lock down the steps of entering data.

I have an unbound field in a form and a button. When the user presses the button I want the form to close, and a new form to open with that data now entered on the new form.

How do I pass that data from the unbound field to the field on the next form. (This is not really pre-filtering because the new form that opens is free of any data)

 
1 Method:

Open a new module. Declare a global variable.

Public gstrMyField as string

When you hit that button, code behind that button should populate that gstr.

gstrMyField = Me.[MyControl]
docmd.close
docmd.openform.... etc

WIth th eon activate part of the newly opened form, you revers the above:

me.[MyControl] = gstrMyField

------------------------
Hit any User to continue
 
Either store the value in a Public variable or pass it in via the OpenArgs parameter of the DoCmd.OpenForm method (the latter is preferred)

In either case in the Form_Load event of the new form pick up the value from where it has been stored and put it into the appropriate unbound textbox.
 
I am a newbie, so this might be a totally stupid question... ON public variables...


What happens if two users call upon the variable at the same time from different PC's? is that irrelevant?
 
Access uses VBA code to perform functions.

Each function is called upon, based on an Event. An event is fired when something happens.. like a form opens (this is called the "On_Open" event.)

Something like clicking a button will be an "On_Click" event.

A variable is a container that holds information temporarily. In the case of a public/global variable, this is valid until you eithe rchange it's data yourself, or you close the DB down. You can create public/global variables by creating a new module and typing:

Public gstrMyNewGlobalVariable as String
-or-
Public anothervarianttypevariable as Variant

Each user will not use the same variable content, as each has invoked a seperate instance of the jet engine (I beleive that is the reason). So like you said, it is irrelevant.

HTH's :D


------------------------
Hit any User to continue
 
btw .. no questions are stupid.. its only stupid not to ask them :D

------------------------
Hit any User to continue
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top