Auto populate

T

Tony F

I have a database built using Access 2000 which contains a form for adding to
the main Table. In the form is a txt box which I want to auto populate from a
combobox, I have the VBA code below where PartDescription is the txt box I
want to populate and PartNumberAffected is the ComboBox.

Private Sub Combo100_AfterUpdate()

Me.PartDescription = Me.PartNumberAffected.Column(1)

End Sub

Behind PartNumberAffected is 2 column table and it's column count is 2, the
main table has one to many relationships which include the PartnumberAffected
table.

When I select a value from the drop down list on my form the following error
occurs

"Compile Error: Method or data member not found" and ".Column" highlighted.

Can you tell me where I'm going wrong.

Many thanks

Tony F
 
J

Jeanette Cunningham

Hi Tony,
make sure the combo has a column count of 2 and the bound column is 1.
On its property dialong, format tab, column count.
Double check the names of the controls and fields.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
T

Tony F

Hello Jeanette

Thanks for your prompt response.

Combo column count is 2, bound column is now 1 (was 0), double checked the
names, all seems as it should be but I still get the previously reported
error?

Tony F
 
J

John W. Vinson

I have a database built using Access 2000 which contains a form for adding to
the main Table. In the form is a txt box which I want to auto populate from a
combobox, I have the VBA code below where PartDescription is the txt box I
want to populate and PartNumberAffected is the ComboBox.

Private Sub Combo100_AfterUpdate()

Me.PartDescription = Me.PartNumberAffected.Column(1)

End Sub

Behind PartNumberAffected is 2 column table and it's column count is 2, the
main table has one to many relationships which include the PartnumberAffected
table.

When I select a value from the drop down list on my form the following error
occurs

"Compile Error: Method or data member not found" and ".Column" highlighted.

Can you tell me where I'm going wrong.

Many thanks

Tony F

Do you perhaps have PartNumberAffected as the name of both the field, and of
the combo box bound to that field? That could be the problem. Try changing the
name of the combo to (say) cboPartNumberAffected and use that name in the
code.

I'd really have to question whether you should be storing the description AT
ALL, since it can just be looked up. The description field should exist only
in the parts table! You can display it with no code at all by setting the
control source of the PartDescription textbox to

=cboPartNumberAffected.Column(1)
 
T

Tony F

John W. Vinson said:
Do you perhaps have PartNumberAffected as the name of both the field, and of
the combo box bound to that field? That could be the problem. Try changing the
name of the combo to (say) cboPartNumberAffected and use that name in the
code.

I'd really have to question whether you should be storing the description AT
ALL, since it can just be looked up. The description field should exist only
in the parts table! You can display it with no code at all by setting the
control source of the PartDescription textbox to

=cboPartNumberAffected.Column(1)
Hello John
That was it, conflict between the names.

Many thanks

Tony F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top