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

  • Follow


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?
0
Reply Utf 3/29/2010 6:13:02 PM

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

-- 
Marsh
MVP [MS Access]
0
Reply Marshall 3/29/2010 7:43:22 PM


"Marshall Barton" wrote:

> 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).
> 
> -- 
> 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?
0
Reply Utf 3/30/2010 5:54:20 PM

Kathy wrote:
>
>"Marshall Barton" wrote:
>
>> 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.

-- 
Marsh
MVP [MS Access]
0
Reply Marshall 3/30/2010 7:45:17 PM


"Marshall Barton" wrote:

> Kathy wrote:
> >
> >"Marshall Barton" wrote:
> >
> >> 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.
> 
> -- 
> Marsh
> MVP [MS Access]
> .
The BoxNo field was a number.  Thanks for all your suggestions.  I was able 
to get the form working.
0
Reply Utf 3/30/2010 9:37:01 PM

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
0
Reply Utf 3/31/2010 8:16:01 PM

5 Replies
1559 Views

(page loaded in 0.166 seconds)


Reply: