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

Using Combo selections to fill fileds on a subform

Status
Not open for further replies.

puforee

Technical User
Oct 6, 2006
741
US
A short while ago I was taught to use -

"Private Sub Combo24_AfterUpdate()
Me.Procedure ID = Me.Combo24.Column(1)
End Sub"

-to store a combo column in a field on a form (Update action). (This is the type of code I was shown and used. The code shown here is what I am trying to use.)

I now find my-self wanting to do this on a sub form.

The form name is "Procedures" The subform name is "Related Procedures tbl subform"

Combo24 on the subform contains many columns. On the Combo update action I want to fill in the rest of the fields on the sub form with the results of the combo box columns.

When I open the form and select the subform and select an item on the comb24 list it trys to update the field as shown in the example above....I get this message: "Compile error: Method or data member not found"

Do I have to further qualify my code because I am dealing with a subform?

Can anyone show me the code that might work for the example I showed above. The fields and form names are actually the ones I am using.

Thanks,
 
It depends on whether the code is to go on the subform or on the main form.

Code on the subform, combo on the main form:

Me.txtID=Me.Parent.cboCombo.Column(1)

Code on the main form, combo on the main form:

Me.[Name of subform control, not form contained].Form.txtID=Me.cboCombo.Column(1)
 
All almost understand this...let me answer your question so you might refine your answer.

The Form is open and the subform is where the work will be done.

The combo box is on the subform (Combo24). The code will go in the combo "After Update" event...so I guess it is on the subform also. The fileds to be loaded when the code runs are also on the subform.

So, could you use my Form and Sub Form and Combo Name and the target field (only one right now) is "Procedure ID".

I would really appreciate it.
 
Is your control called Procedure ID, that is, is there a space? If so, try again like this:

Code:
Private Sub Combo24_AfterUpdate()
    Me.[Procedure ID] = Me.Combo24.Column(1)
End Sub
 
Remou....we are working fine now. I have to learn to stop copying and pasteing. When I typed the first Me. It gave me a list and I picked the Procedure_ID. So, Me works on the subform...good to hear.

Thanks for leading me to the correct answer.

:-D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top