Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Transfer values between form and subform

Robson8112 (TechnicalUser) (OP)
12 Sep 02 10:56
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?
hermanlaksko (Programmer)
12 Sep 02 11:32
On the after update event on the combo try this:
forms!YrForm.Form!YrSubForm!Yrfield=me!YrCombo

Herman
Robson8112 (TechnicalUser) (OP)
12 Sep 02 11:42
is that in the code or propeties of the combo box?
hermanlaksko (Programmer)
12 Sep 02 11:53
Events is allways the code
Robson8112 (TechnicalUser) (OP)
13 Sep 02 3:59
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!

mrf1xa (TechnicalUser)
13 Sep 02 4:20
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....

Robson8112 (TechnicalUser) (OP)
13 Sep 02 5:30
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
hermanlaksko (Programmer)
13 Sep 02 5:35
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
mrf1xa (TechnicalUser)
13 Sep 02 5:48
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....

Robson8112 (TechnicalUser) (OP)
13 Sep 02 5:51
still aint working, says it cant find on of my forms?  which is definatly there and spelled correctly.

Runtime Error 2465



hermanlaksko (Programmer)
13 Sep 02 5:58
Show us the code rob - perhaps there is the answer
Robson8112 (TechnicalUser) (OP)
13 Sep 02 6:06
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.
danvlas (Programmer)
13 Sep 02 6:11
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?


Daniel Vlas
Systems Consultant
danvlas@yahoo.com

Robson8112 (TechnicalUser) (OP)
13 Sep 02 6:18
No still no joy,  i requery every time the combo box is changed.

this is doing my tree in now!
danvlas (Programmer)
13 Sep 02 6:57
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


Daniel Vlas
Systems Consultant
danvlas@yahoo.com

Robson8112 (TechnicalUser) (OP)
13 Sep 02 7:05
Sweet as a nut!!  Cheers danvlas
mrf1xa (TechnicalUser)
13 Sep 02 7:08
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....

Robson8112 (TechnicalUser) (OP)
13 Sep 02 7:10
Cheers for the help

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close