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

Form to Form

Status
Not open for further replies.

mrkshpntf

MIS
Apr 19, 2007
92
US

I have two forms.

Data entered in text boxes on the first form is displayed in corresponding text boxes on the second form.

What happens is, once data is entered on the first form and an openForm button is clicked, the second form opens and displays the data entered on the first form.

But this happens only for the first record page of the second form.

The subsequent record pages do not show the data from the first form's text boxes.

I would like every record page of the second form to show this data once it has been entered on the first form and the openForm button is clicked. This should should end when the second form is closed. The process can start all over again when the first form is reopened.

Also, is there a way to close the first form after entering the data in the text boxes and clicking on the openForm button?

I know it is a roundabout way of doing things but my colleagues want the process to flow in this manner.

Please help.

Thanks,
mrkshpntf.
 
What is the actual code of the openForm button click event procedure and how are the values transferred to the second form ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV,

Here's the code:

------------------

Forms!firstForm!textbox1.Requery
Forms!secondForm!textbox1 = Me!textbox1

Forms!firstForm!textbox2.Requery
Forms!secondForm!textbox2 = Me!textbox2

----------------------------------

Thanks
mrkshpntf.
 
You may try to play with the DefaultValue property of the texboxes in the second form.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 

PHV,

I did play with defaultValue property.

I entered (=Forms!firstForm!textbox1) in the defaultValue of the textbox1 of the secondForm.

It works fine with the first record page of the second form but gives this '#error' in the subsequent record pages.

Thanks,
mrkshpntf.
 
I suspect that if you closed the first form you wouldn't even get the values in the first record on form two. Is this the only way these two values are entered in form two? In other words, do you sometimes open up form two and enter Textbox1 and Textbox2 manually, or will it always be "transferred" from form one. If it will always be "transferred" from form one, I'd declare two global variables in a standard module for transferring the two values.

In form one:
Code:
Private Sub CommandButtonToOpenFormTwo_Click()
  GlobalVariableOne = Me!textbox1 
  GlobalVariableTwo = Me!textbox2
  'Code to open form two goes here
End Sub

Then in form two:

Code:
Private Sub Form_Current()
If Me.NewRecord Then
  Me.Textbox1 = GlobalVariableOne
  Me.Textbox2 = GlobalVariableTwo
End If

End Sub

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 


Missinglinq,

No, this is not the only way of entering data in Form2 but is what the co-workers who will use the form want.

I entered the code you gave me in the appropriate location.

The second Form doesn't hold the entered data beyond the first recod page.
 
The Second Form doesn't hold the entered data beyond the first recod page.
I assumed these were new records. Is this true or are they or they existing records?

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 


missinglinq,

Yes, these are new records. Both forms 1 & 2 are exclusive data entry forms (dataEntry property is set to 'yes').
The reason for this is to allow users to keep entering data in the rest of the form2 once they have entered their ID number and name (textboxes 1 & 2 respectively). Every new record they work on bears their ID and name.

I have a copy of form2 for viewing existing records. This copy is accessed through the switchboard form and is not a part of the above mentioned process.

Thanks,
mrkshpntf.
 
How are ya mrkshpntf . . .

From your post origination:
mrkshpntf said:
[blue]But this happens only for the first record page of the second form.

The subsequent record pages do not show the data from the first form's text boxes.[/blue]
Then in your latest post to [blue]missinglinq[/blue]:
mrkshpntf said:
[blue]Yes, these are new records. Both forms 1 & 2 are exclusive data entry forms . . .[/blue]
The above two quotes are indicitive of taging each new record with that origionally passed to form2! [blue]Is this not correct?[/blue]

If true, then [blue]PHV[/blue] is on target with his prescription of setting the [blue]Default Values[/blue]. You indicated you tried setting the [blue]Default Values[/blue] but were unsuccessful. That doesn't mean its not the way to go (which it appears to me like [blue]PHV[/blue] . . . it is!). [blue]PHV[/blue] has already asked but I reiterate . . . post the code that transfers the data from form1 to form2.

If not true, then you need to be more specific . . .

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
I did play with defaultValue property.
I entered (=Forms!firstForm!textbox1) in the defaultValue of the textbox1 of the secondForm.

That is not the defaultvalue property. Something like this works fine.

Code:
Private Sub btn1_Click()
  DoCmd.OpenForm "form2"
  Forms("form2").text2.DefaultValue = "'" & Me.text1 & "'"
End Sub
 
We absolutely need to see the code. Both PHV's approach and mine should work! Another thing jumps out at me after reading the OP's recent post. It appears to me that the whole purpose in having the first form is so that the use can enter their name and ID. It would be much simpler to set the defaults from these controls on the second form, rather than involving two forms.

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top