PDA

Click to See Complete Forum and Search --> : [RESOLVED] Transferring Strings Between Two Forms


apollo101
Jul 29th, 2005, 04:58 PM
In Access I have 2 Forms. Main and Secondary.
On the Main form I have a cmdButton that opens the second form using and OpenForm command.

I have text boxes on the main form that take user input as strings. I want to be able to transfer those strings to the secondary form for use, or at least be able to reference them, but have been unable to do so.

I tried referencing with a line like StringVariable = Main.txtBox.Text but was unsuccessful. Any advice would be much appreciated. Thanks.

RobDog888
Jul 29th, 2005, 05:40 PM
Why not just reference the controls that contain the strings?
Forms![Form2]![txtString2].Text = Forms![Form1]![txtString1].TextOr you could use a public variable in a module.

apollo101
Aug 2nd, 2005, 11:25 AM
Robdogg, thanks for the Reply, but a couple of questions.
1.I would prefer to create a public variable but each form has its own module of code. So creating a public variable on one does not apply to the other as I know it. How would I do that then?
2. In regards to the sample you posted: what does the '!' mean?
Why did the code begin with 'Forms!' ?

RobDog888
Aug 2nd, 2005, 11:30 AM
1. You can create a new general Module from the Modules section in Access. Then create a Public variable of the type you need. You will now be able to access that variable from anywhere throughout Access.

2. It starts with "Forms" because its the forms collection and we are wanting to access an item in the collection. The "!" is similar to the ".". ;)

apollo101
Aug 2nd, 2005, 12:40 PM
Ah! A new general Module... I love it!
Thanks