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

Transfer values between form and subform

Status
Not open for further replies.

Robson8112

Technical User
Sep 5, 2002
39
0
0
GB
How do I transfer a selected option from a combo box on a form, to a text box on a subform, which is within the same form?

So, when i select an option, it displays that same option in a text box in a subform?

Anyone know?
 
On the after update event on the combo try this:
forms!YrForm.Form!YrSubForm!Yrfield=me!YrCombo

Herman
 
is that in the code or propeties of the combo box?
 
it gives me a Macro error, saying cannot find macro?

this is the code i entered:

Forms!Change_test.form!Change_subform!txtMasterServer = Me!CboSelectServer

Help!

 
You'll need to add some brackets, and I suspect you are putting it in the wrong place if it is looking for a macro name. I'll do it step by step with apologies if I am teaching grandmother to suck eggs.

1) Go to the properties box for your combo and find the AfterUpdate event.
2) Using the dropdown arrow select Event Procedure. Then click just to the right of the AfterUpdate line and the build button will appear- it has 3 little dots on. Click it and you will be taken to the code window, which will strat off with the line Private Sub cboSelectServer_AfterUpdate().
3) Depending on how you made your combo there may some code already following this. This doesn't matter. You need to add your line of code just before the line that says Exit cboSelect_Server_AfterUpdate (if there is code present) or before the End Sub line if there is no code there already.
4) Your code should read:
Forms![Change_test]!Form![Change_subform]!txtMasterServer] = Me.CboSelectServer
5) Close the code window and give it a whirl.

HTH Nigel
Didn't someone say work is supposed to be fun? They didn't have computers then I guess....
 
Still didnt work, i've added the code just like to said, and for some reason the code turns red???

the form runs with no errors, but it still doesnt work
 
Hi Robson

Use this, it works:
Forms!Change_test.form!Change_subform!txtMasterServer = Me!CboSelectServer
you get the red text owing to the "." in Me.CboSelectServer
 
OK, I hold my hands up in shame- sorry to lead you astray there Robson! Nigel
Didn't someone say work is supposed to be fun? They didn't have computers then I guess....
 
still aint working, says it cant find on of my forms? which is definatly there and spelled correctly.

Runtime Error 2465



 
im not getting errors now, but nowt aint happening. here my code

Private Sub CboSelectServer_AfterUpdate()

Requery

Forms!Change_test.Form!Change_Subform!txtMasterServer = Me!CboSelectServer

End Sub

if u want the code for that whole form, just ask.
 
Is this a typo?
Forms!Change_test.Form!Change_Subform!txtMasterServer = Me!CboSelectServer

Shouldn't it be:
Forms!Change_test!Change_Subform.Form!txtMasterServer = Me!CboSelectServer


And...Why do you Requery?
[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
No still no joy, i requery every time the combo box is changed.

this is doing my tree in now!
 
Private Sub CboSelectServer_AfterUpdate()
Me("Change_subform")("txtMasterServer") = CboSelectServer
End Sub

This should do the trick.
If not, double check that:

CboSelectServer is the exact name of the combo on the main form

Change_subform is the exact name of the subform as control[/] on the main form

txtMasterServer is the exact name of the text box you want to change on the subform

[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
OK, have just created following in test db:

Form called Change_Test with combo called cboSelectServer on- set some simple values for combo

Subform called Change_Subform with text box called txtMasterServer on.

The following code works perfectly to update the textbox:

Forms!Change_test!Change_Subform.Form!txtMasterServer = Me!CboSelectServer

Dan's alternative also works fine. So, any further issues must be as a result of naming issues on your db.

HTH
Nigel
Didn't someone say work is supposed to be fun? They didn't have computers then I guess....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top