I've got a simple question, how do i pass information (lets say a name that is input in a textbox) to another form
Thanks
6 2818
Depends on how you want to pass it. If you want to pass it from, say, FormA to FormB, when opening FormB, the best way would to use OpenArgs.
In your calling form: - Private Sub OpenFormB_Click()
-
DoCmd.OpenForm "FormB", , , , , , Me.FieldToPass
-
End Sub
-
Then, in FormB: - Private Sub Form_Load()
-
If Len(Nz(Me.OpenArgs, "")) > 0 Then
-
Me.WhateverField = Me.OpenArgs
-
End If
-
End Sub
If both forms are already open, you could assign the data to pass to a global variable, or simply explicitly reference it as a control on the first form.
Linq ;0)>
[quote=missinglinq]Depends on how you want to pass it. If you want to pass it from, say, FormA to FormB, when opening FormB, the best way would to use OpenArgs.
In your calling form: - Private Sub OpenFormB_Click()
-
DoCmd.OpenForm "FormB", , , , , , Me.FieldToPass
-
End Sub
-
Then, in FormB: - Private Sub Form_Load()
-
If Len(Nz(Me.OpenArgs, "")) > 0 Then
-
Me.WhateverField = Me.OpenArgs
-
End If
-
End Sub
If both forms are already open, you could assign the data to pass to a global variable, or simply explicitly reference it as a control on the first form.
Linq ;0)>[/QUOTE
Thank you so much, i think that will work, but is there some way to pass multiple values such as Me.txtFirstname, Me.txtLastname??
Thanks
- You can pass as many Values as you like in the OpenArgs Argument of the OpenForm() Method as long as you use a Common Delimiter between then.
- In the following example, I'll pass 4 Values (Argument 1 to Argument 4) to Form2 via the OpenArgs Argument of the OpenForm() Method:
-
DoCmd.OpenForm "Form2", acNormal, , , acFormEdit, acWindowNormal, "Argument 1,Argument 2,Argument 3,Argument 4"
- In the receiving Form, you can use the Split() Function to retrieve the variable number of Values:
-
Dim varOpenArgs As Variant
-
Dim intCounter As Integer
-
-
varOpenArgs = Split(Me.OpenArgs, ",")
-
-
For intCounter = LBound(varOpenArgs) To UBound(varOpenArgs)
-
Debug.Print varOpenArgs(intCounter)
-
Next
OUTPUT: -
Argument 1
-
Argument 2
-
Argument 3
-
Argument 4
Thanks folks both of those posts worked like a charm, but i have one more problem that i ran into.
I need to pass the current primary key value, which is displayed in a textbox, from form1 which is made off of table Patient to form2 which is made off of table IV. Table Patient and Table IV are linked in a one to many relationship and the joining column is PatientID.
I currently have PatientID on both forms, and when i pass it the way you all showed me the status bar on form2 says "Control can't be edited; it's bound to AutoNumber field 'PatientID'. I get what this is saying, but i dont know how to "work around" it.
Ideally what this should do is in form1 the user is viewing a patient (with a unique PatientID) they click the "NewIV" button and access opens up form2 and lets the user add a new IV to the patientID that was passed to it.
I really appreciate all the help Bytes has given me over the course of this project. Thanks for any responses
Matt
Thanks folks both of those posts worked like a charm, but i have one more problem that i ran into.
I need to pass the current primary key value, which is displayed in a textbox, from form1 which is made off of table Patient to form2 which is made off of table IV. Table Patient and Table IV are linked in a one to many relationship and the joining column is PatientID.
I currently have PatientID on both forms, and when i pass it the way you all showed me the status bar on form2 says "Control can't be edited; it's bound to AutoNumber field 'PatientID'. I get what this is saying, but i dont know how to "work around" it.
Ideally what this should do is in form1 the user is viewing a patient (with a unique PatientID) they click the "NewIV" button and access opens up form2 and lets the user add a new IV to the patientID that was passed to it.
I really appreciate all the help Bytes has given me over the course of this project. Thanks for any responses
Matt
It appears that what you need is to use the Where Argument of the OpenForm() Method and not OpenArgs, something like: -
DoCmd.OpenForm "Form2", acNormal, , "[PatientID] = " & Me![PatientID], acFormEdit
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Vanessa |
last post by:
Hi,
I would like to know whether there's any way for me to pass an object by
reference to another form?
Regards
Vanessa
|
by: Don Seckler |
last post by:
I have a data entry form called Draw. This form is used to enter data
in the table called Draw. The table has the following fields:
WholesalerID, MagID, IssueID, CopiesDist, and the index is...
|
by: deko |
last post by:
I'd like to use a bit of code in the OnOpen event of a report:
=rptOpen(Me.ReportName), (Me.Tag) --this doesn't work
This does work:
Private Sub Report_Open(Cancel As Integer)...
|
by: Lyn |
last post by:
Hi,
I have been experiencing a problem passing a LIKE statement in the WHERE
argument of a DoCmd.Openform statement. I have posted that issue
separately.
However, in an attempt to work around...
|
by: Fresh Air Rider |
last post by:
Hello
Could anyone please explain how I can pass more than one
arguement/parameter value to a function using <asp:linkbutton> or is
this a major shortfall of the language ?
Consider the...
|
by: Martin |
last post by:
I have a calendar form that sends the inputted date back to a text box .
Using the GET method, I would like to pass the date as a variable to another
asp page. How do I do this?
Thanks.
|
by: Boki |
last post by:
Hi All,
I can't pass data to another form:
in form2:
private void button1_Click(object sender, EventArgs e)
{
Form1 form_copy = new Form1();
|
by: Kevin Blount |
last post by:
I'm having a very odd issue, that arose this morning after working
fine yesterday...
here's a very simple script:
1: <?php
2: $test = $_GET;
3: echo "Hello" . $test . "<p>";
4: ?>
|
by: magickarle |
last post by:
Hi, I got a pass-through query (that takes about 15 mins to process)
I would like to integrate variables to it.
IE: something simple:
Select EmplID from empl_Lst
where empl_lst.timestamp between...
|
by: raylopez99 |
last post by:
Keywords: scope resolution, passing classes between parent and child
forms, parameter constructor method, normal constructor, default
constructor, forward reference, sharing classes between forms....
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |