Populating fields

  • Thread starter Thread starter Devon
  • Start date Start date
D

Devon

I am trying to figure out how to autopopulate several
fields on a form based on what is entered in the first
field. There will be several (more than 20, but less than
100) different options that can be entered into the first
field.
I have seen several scenarios in the newsgroup, but
nothing that has been specific enough to help me. I am
fairly comfortable with Access, but am just starting to
learn VBA.
Can someone be very specific and tell me what VBA code
could be used, and where this VBA code would be stored?
For this example, lets say that Field1 is the field being
filled in, and based on what is in that field, field2,
field3, and field4 will be populated. All fields will be
stored on the same table. Field1 would probably have a
list box for the different choices.
I have been told that I should try a Select Case with an
If Then subprocedure, but just not sure if that is
correct, or how it might look.

Thanks in advance.
 
Devon said:
I am trying to figure out how to autopopulate several
fields on a form based on what is entered in the first
field. There will be several (more than 20, but less than
100) different options that can be entered into the first
field.
I have seen several scenarios in the newsgroup, but
nothing that has been specific enough to help me. I am
fairly comfortable with Access, but am just starting to
learn VBA.
Can someone be very specific and tell me what VBA code
could be used, and where this VBA code would be stored?
For this example, lets say that Field1 is the field being
filled in, and based on what is in that field, field2,
field3, and field4 will be populated. All fields will be
stored on the same table. Field1 would probably have a
list box for the different choices.
I have been told that I should try a Select Case with an
If Then subprocedure, but just not sure if that is
correct, or how it might look.

If your list or combo box's Rwo Source contains all the
desired fields from the table, then you can refer to them
using the box's Column property. E.g

If the Row Source is a query like:

SELECT Field1, Field2, Field 3, Field4
FROM thetable
ORDER BY Field1

and the list/combo box's Column count is 4 and the bound
column is 1, then you can copy the fields to other controls
using code in the box's After Update event:

Me.txtField2 = cboField1.Column(1)
Me.txtField3 = cboField1.Column(2)
Me.txtField4 = cboField1.Column(3)

If all you want to do is display those field and not save
them in a new table record, then you don't need any code at
all. Just use an expression in the text boxes:

=cboField1.Column(1)
 
Marshall

That is exactly what I needed.

Thanks
-----Original Message-----


If your list or combo box's Rwo Source contains all the
desired fields from the table, then you can refer to them
using the box's Column property. E.g

If the Row Source is a query like:

SELECT Field1, Field2, Field 3, Field4
FROM thetable
ORDER BY Field1

and the list/combo box's Column count is 4 and the bound
column is 1, then you can copy the fields to other controls
using code in the box's After Update event:

Me.txtField2 = cboField1.Column(1)
Me.txtField3 = cboField1.Column(2)
Me.txtField4 = cboField1.Column(3)

If all you want to do is display those field and not save
them in a new table record, then you don't need any code at
all. Just use an expression in the text boxes:

=cboField1.Column(1)
 
Back
Top