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!

Need data in a text box's that is on a different form 1

Status
Not open for further replies.

Patentinv

Technical User
Aug 26, 2005
84
US
Hi, I have a form in access 2003 we'll call the master form that has a macro in a command button to popup form. On this popup form I have a few text boxes that have numbers in them that I need to use in the master form. Since each form is bound to a different table the master form can not see the numbers in the popup form.
Can any one provide a way to make the master form see these text boxes numbers in the pop up form?

Thanks--any help will be greatly appreciated.
 
Hi
I think the best way would be to say (on the pop-up form), something like:
[tt]Forms!MasterFormName.TextBoxName=Me.TextBoxName[/tt]
 
Hi, Remou
Where would I place this code? I placed it in the text boxes control source. But it gives an error. Looks like this.
Forms!PrimaryBid_Master.txtfld=Me.txtfldlbr.


Thanks--for your help.
 
In the After Update event of Me.txtfldlbr or if Me.txtfldlbr is already there, in the Form Load event for the pop-up, perhaps.
 
Remou and Patentinv,
Me.txtBxname will only work if your field name and text box have the same name. Naming controls on form and fields with the same name is the default, but it is considered good coding standard and can lead to problems.
Assuming your text box and field have different names the following works to reference a value of a control:

Forms!MasterFormName.controls("TextBoxName")
Forms!MasterFormName("TextBoxName")
Forms!MasterFormName.controls!TextBoxName
Forms!MasterFormName!TextBoxName

To reference the field
Forms!MasterFormName.fieldName
works since all fields become a property of the form

You may need to have both forms open when you save the popup so that it can see the master form that you are referring to. You may also have to refresh the control. The control may get passed the value, but it may not get placed in the control buffer. I have not tried it, but I am guessing.
with Forms!PrimaryBid_Master
.txtfld=Me.txtfldlbr
.refresh
enc with
 
Oops,
Forget the refresh, I meant requery. But you do not need it. Your main form would be my "frmSynch1" the popup is "frmSynch2"
Code:
Private Sub Form_Open(Cancel As Integer)
Forms("frmSynch1").Controls("txtBxOne").Value = Me.Controls("txtBxPopUp").Value
End Sub

Private Sub txtBxPopUp_AfterUpdate()
Forms("frmSynch1").Controls("txtBxOne").Value = Me.Controls("txtBxPopUp").Value
End Sub

Private Sub txtBxPopUp_Change()
Forms("frmSynch1").Controls("txtBxOne").Value = Me.Controls("txtBxPopUp").Text
End Sub
In the change event I use the "text" not the "value" property. The value in the text box does not change until the before update event so what you see in the text box is not the value of the text box until it is saved. This way it looks as if the two forms are completly synched. You type a letter in the pop up and you will see it immediately in the main.
 
Hi Majp,
I see what you are attemting to accomplish, but that is not what I need, sorry about the miscommunication.

What I need to accomplish is a little different, I need to have the popup form text box which is called (TOTFLDSQLBR) display the value that is in a text box called (TOTFLDSQ) in the PrimaryBid_Master form. How ever the textbox (TOTFLDSQ) that is in the PrimaryBid_Master form has a
control source=[txtfld]+[Xtrasqrs] which is a calculation which refer to values in two other text boxes.

I'm not sure if this calculation gets calculated every time you reference this text box or if it calculates the sum automatically and stores the sum so i can use it in the popup form?

Thanks--Any help/suggestions will be greatly appreciated.



 
How are ya Patentinv . . .

[ol][li]A textbox can either show the value of the field its bound too, or the result of an equation in the controlsource . . . not both![/li]
[li]When using the controlsource of an unbound textbox, naturally only one equation allowed![/li]
[li]Because of the above, you have two choices:
[ol a][li]Incorperate the master form reference as part of the existing equation (something like):
[blue]=[txtfld]+[Xtrasqrs]+Forms!MasterFormName!TOTFLDSQ[/blue][/li]
[li]Instantiate a new unbound textbox with the equation:
[blue]=Forms!MasterFormName!TOTFLDSQ[/blue][/li][/ol][/li]
[/ol]
Nothing else you can do . . .

Calvin.gif
See Ya! . . . . . .
 
Not sure what you want to do once you put the pop up form value in the main. If you want to switch to the popup form as the control source maybe.
Code:
Private Sub Form_Open(Cancel As Integer)
'switch it to unbound
Forms("frmSynch1").Controls("TOTFLDSQ").ControlSource = ""
Forms("frmSynch1").Controls("TOTFLDSQ").Value = Me.Controls("txtBxPopUp").Value
End Sub
Or what the AceMan said depending on how you want it to function.
 
Hi Aceman1,
I'm doing good. How about your self? I don't know what I'd do with out your help, once again your suggestion has solved my problem, I can't thank you enough. I used suggestion b.
I had to modify my macro so it would not close the PrimaryBid_Master form when opening the popup form labor. I'm guessing the form must stay open in order to retrieve the data.

Thanks MajP and Remou for your suggestions.

Sorry about the late response.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top