|
-
Jul 29th, 2005, 04:58 PM
#1
Thread Starter
New Member
[RESOLVED] Transferring Strings Between Two Forms
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.
-
Jul 29th, 2005, 05:40 PM
#2
Re: Transferring Strings Between Two Forms
Why not just reference the controls that contain the strings?
VB Code:
Forms![Form2]![txtString2].Text = Forms![Form1]![txtString1].Text
Or you could use a public variable in a module.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 2nd, 2005, 11:25 AM
#3
Thread Starter
New Member
Re: Transferring Strings Between Two Forms
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!' ?
-
Aug 2nd, 2005, 11:30 AM
#4
Re: Transferring Strings Between Two Forms
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 ".".
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 2nd, 2005, 12:40 PM
#5
Thread Starter
New Member
Re: Transferring Strings Between Two Forms
Ah! A new general Module... I love it!
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|