Combo Box to select a record and populate fields in a form

K

Kathy

I have created a form where I've created a combo box that has a drop down
list of box numbers where I want to be able to select one box number and have
it populate the other fields on the form.

On the combo box, I have entered the following for "after update", but it
doesn't allow me to select a record and doesn't populate any of the other
fields for that record.

Sub Combo74_AfterUpdate()
' Find the record that matches the control.
Me.Filter = "[BoxNo] = """ & Me.Combo74 & """"
Me.FilterOn = True
End Sub

What am I missing to make this work?
 
M

Marshall Barton

Kathy said:
I have created a form where I've created a combo box that has a drop down
list of box numbers where I want to be able to select one box number and have
it populate the other fields on the form.

On the combo box, I have entered the following for "after update", but it
doesn't allow me to select a record and doesn't populate any of the other
fields for that record.

Sub Combo74_AfterUpdate()
' Find the record that matches the control.
Me.Filter = "[BoxNo] = """ & Me.Combo74 & """"
Me.FilterOn = True
End Sub

Well, that code should find the desired record as long as
there is one that has its BoxNo Text field that matches the
BoundColumn of the combo box's selected row. If, as the
name implies, BoxNo is a number type field in its table,
then you should have gotten an error message, in which case
the code should not include the extra quote:
Me.Filter = "[BoxNo] = " & Me.Combo74

But there is nothing in the code to populate anything. Are
the text boxes that you want to populate using expressions
like =Combo74.Column(n) (the common way to display the
other values) or do you actually want to copy the values to
bound text boxes so thery are saved back to the table
(generally not a good idea).
 
K

Kathy

Marshall Barton said:
Kathy said:
I have created a form where I've created a combo box that has a drop down
list of box numbers where I want to be able to select one box number and have
it populate the other fields on the form.

On the combo box, I have entered the following for "after update", but it
doesn't allow me to select a record and doesn't populate any of the other
fields for that record.

Sub Combo74_AfterUpdate()
' Find the record that matches the control.
Me.Filter = "[BoxNo] = """ & Me.Combo74 & """"
Me.FilterOn = True
End Sub

Well, that code should find the desired record as long as
there is one that has its BoxNo Text field that matches the
BoundColumn of the combo box's selected row. If, as the
name implies, BoxNo is a number type field in its table,
then you should have gotten an error message, in which case
the code should not include the extra quote:
Me.Filter = "[BoxNo] = " & Me.Combo74

But there is nothing in the code to populate anything. Are
the text boxes that you want to populate using expressions
like =Combo74.Column(n) (the common way to display the
other values) or do you actually want to copy the values to
bound text boxes so thery are saved back to the table
(generally not a good idea).

--
Marsh
MVP [MS Access]
.
When I say I want to popluate the other fields, I just want it to pull up the rest of the fields from the same record as the BoxNo that is selected in the combo box. I do not want to copy anything. Are we talking about the same thing?
 
M

Marshall Barton

Kathy said:
Marshall Barton said:
Kathy said:
I have created a form where I've created a combo box that has a drop down
list of box numbers where I want to be able to select one box number and have
it populate the other fields on the form.

On the combo box, I have entered the following for "after update", but it
doesn't allow me to select a record and doesn't populate any of the other
fields for that record.

Sub Combo74_AfterUpdate()
' Find the record that matches the control.
Me.Filter = "[BoxNo] = """ & Me.Combo74 & """"
Me.FilterOn = True
End Sub

Well, that code should find the desired record as long as
there is one that has its BoxNo Text field that matches the
BoundColumn of the combo box's selected row. If, as the
name implies, BoxNo is a number type field in its table,
then you should have gotten an error message, in which case
the code should not include the extra quote:
Me.Filter = "[BoxNo] = " & Me.Combo74

But there is nothing in the code to populate anything. Are
the text boxes that you want to populate using expressions
like =Combo74.Column(n) (the common way to display the
other values) or do you actually want to copy the values to
bound text boxes so thery are saved back to the table
(generally not a good idea).
When I say I want to popluate the other fields, I just want
the BoxNo that is selected in the combo box. I do not
want to copy anything. Are we talking about the same thing?


No, we were talking about two different things. Displaying
the matching record's fields should be automatic as long as
the controls are bound to fields in the form's record source
table/query.

Did you determine if the type of the BoxNo field is Text or
Number?

Remember that it is common for a combo box to display some
text while it's value is a number used as a foreign key to a
table. Compare the combo box's BoundColumn and ColumnWidths
properties. Also check that the field in the combo box's
RowSource table/query corresponds to the field index in the
BoundColumn property.
 
K

Kathy

Marshall Barton said:
Kathy said:
Marshall Barton said:
Kathy wrote:

I have created a form where I've created a combo box that has a drop down
list of box numbers where I want to be able to select one box number and have
it populate the other fields on the form.

On the combo box, I have entered the following for "after update", but it
doesn't allow me to select a record and doesn't populate any of the other
fields for that record.

Sub Combo74_AfterUpdate()
' Find the record that matches the control.
Me.Filter = "[BoxNo] = """ & Me.Combo74 & """"
Me.FilterOn = True
End Sub


Well, that code should find the desired record as long as
there is one that has its BoxNo Text field that matches the
BoundColumn of the combo box's selected row. If, as the
name implies, BoxNo is a number type field in its table,
then you should have gotten an error message, in which case
the code should not include the extra quote:
Me.Filter = "[BoxNo] = " & Me.Combo74

But there is nothing in the code to populate anything. Are
the text boxes that you want to populate using expressions
like =Combo74.Column(n) (the common way to display the
other values) or do you actually want to copy the values to
bound text boxes so thery are saved back to the table
(generally not a good idea).
When I say I want to popluate the other fields, I just want
the BoxNo that is selected in the combo box. I do not
want to copy anything. Are we talking about the same thing?


No, we were talking about two different things. Displaying
the matching record's fields should be automatic as long as
the controls are bound to fields in the form's record source
table/query.

Did you determine if the type of the BoxNo field is Text or
Number?

Remember that it is common for a combo box to display some
text while it's value is a number used as a foreign key to a
table. Compare the combo box's BoundColumn and ColumnWidths
properties. Also check that the field in the combo box's
RowSource table/query corresponds to the field index in the
BoundColumn property.
The BoxNo field was a number. Thanks for all your suggestions. I was able
to get the form working.
 
T

tom_willpa

high quality Soccer jerseys NBA Jersey tracksuit and jackets, GHD
hairstraightener supplier from www.willpa.com

Are you a Retail businessman who bother by the purchase price? China
Cheapest TOP wholesale website can help you

we are specialize in replica sport goods manufacturing in china, we can
offer you all kinds of soccer jersey, NBA jersey,shoes and so on. they are
the best brand replica goods whih are look the same as the original goods.
excellent quality and steady supply for them. we have been marketed in Europe
and American for 3 year. all the goods we offer are AAA quality. our soccer
jersey are Thailand style. If any goods you buy from my company have problem,
we will refund or resend them again. Most of ourProducts have no minimum
order requirements,soyou can shop retail goods at wholesale prices. if you
can buy more than 300usd. We offer free shipping. The more you buy the more
discount for you.

National soccer jerseys: http://www.willpa.com
Club soccer jerseys: http://www.willpa.com
NBA Jerseys: http://www.willpa.com
T-shirt and shirt: http://www.willpa.com
Tracksuit: http://www.willpa.com
Hoody & Jackets: http://www.willpa.com
UGG boots: http://www.willpa.com
Hair style: http://www.willpa.com
shopping Index: http://www.willpa.com

EMS shipping. 7days arrive, paypal accept

want more information pls contact us or check our website: www.willpa.com
 

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