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 Forums!
  • 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.

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

Transfer values between form and subform

(OP)
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?

RE: Transfer values between form and subform

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

Herman

RE: Transfer values between form and subform

(OP)
is that in the code or propeties of the combo box?

RE: Transfer values between form and subform

Events is allways the code

RE: Transfer values between form and subform

(OP)
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!

RE: Transfer values between form and subform

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....

RE: Transfer values between form and subform

(OP)
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

RE: Transfer values between form and subform

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

RE: Transfer values between form and subform

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....

RE: Transfer values between form and subform

(OP)
still aint working, says it cant find on of my forms?  which is definatly there and spelled correctly.

Runtime Error 2465



RE: Transfer values between form and subform

Show us the code rob - perhaps there is the answer

RE: Transfer values between form and subform

(OP)
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.

RE: Transfer values between form and subform

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

RE: Transfer values between form and subform

(OP)
No still no joy,  i requery every time the combo box is changed.

this is doing my tree in now!

RE: Transfer values between form and subform

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

RE: Transfer values between form and subform

(OP)
Sweet as a nut!!  Cheers danvlas

RE: Transfer values between form and subform

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....

RE: Transfer values between form and subform

(OP)
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