Populating fields in a form

  • Thread starter Thread starter Jenn
  • Start date Start date
J

Jenn

I want to choose a value from a combo box (that is
looking up values in a table) on my form and have the
next two fields automatically populate from the related
fields in the table.

Any suggestions?
 
Jenn,
This was a reply I sent to a posting that was quite similar to yours and
should answer your question - just change column names etc


Do the following in your combobox.
1. Change the rowsource query of your combobox to include the fields you
need.
for example, select subsnumber, subsname, subsaddress, ... from
tblsubscriber.

2. You can set the combobox's properties to show only the columns you want,
by setting
thecolumnwidths property. In this example, if you only want to show
subsnumber and subsaddress, you could specify that the columnwidths property
as 1", 0", 2"
the 0" will hide subsname.
You can also set the overall width of the dropdown by setting the listwidths
property.

3. in the After_Update event of the combobox, you can grab the values of
each of the additional columns of the rowsource of the combobox - the
current record selected


for example:
Private Sub cboItemID_AfterUpdate()
Me.txtType = Me.cboItemID.Column(2) ' this is the third column of the row
source
Me.TxtLabel = Me.cboItemID.Column(3) ' this is the fourth column of the
rowsource

notice that it is a Zero-based index, meaning the first column is Column(0)

HS
 
Thank so very much!

-----Original Message-----
Jenn,
This was a reply I sent to a posting that was quite similar to yours and
should answer your question - just change column names etc


Do the following in your combobox.
1. Change the rowsource query of your combobox to include the fields you
need.
for example, select subsnumber, subsname, subsaddress, ... from
tblsubscriber.

2. You can set the combobox's properties to show only the columns you want,
by setting
thecolumnwidths property. In this example, if you only want to show
subsnumber and subsaddress, you could specify that the columnwidths property
as 1", 0", 2"
the 0" will hide subsname.
You can also set the overall width of the dropdown by setting the listwidths
property.

3. in the After_Update event of the combobox, you can grab the values of
each of the additional columns of the rowsource of the combobox - the
current record selected


for example:
Private Sub cboItemID_AfterUpdate()
Me.txtType = Me.cboItemID.Column(2) ' this is the third column of the row
source
Me.TxtLabel = Me.cboItemID.Column(3) ' this is the fourth column of the
rowsource

notice that it is a Zero-based index, meaning the first column is Column(0)

HS





.
 
Back
Top