Auto fill a box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

have a form with a few fields I want auto field. I would like to pull the
data from a table that I have set up. Right now im using this code in the
after update to fill in the field.

If Left(Me.Technician, 3) = "Don" Then Me.TECHNICIAN_PHONE = "354"
ElseIf Left(Me.Technician, 3) = "Bob" Then Me.TECHNICIAN_PHONE = "352"
ElseIf Left(Me.Technician, 3) = "Dan" Then Me.TECHNICIAN_PHONE = "354"
ElseIf Left(Me.Technician, 3) = "Phi" Then Me.TECHNICIAN_PHONE = "352"
End If

I have a table named "Technicians" that have both fields for
TECHNICIAN_Phone and TECHNICIAN_EMAIL. I would like those to be entered into
the TECHNICIAN_PHONE and TECHNICIAN_EMAIL in the form. The TECHNICIAN is a
drop down box that selects a name from the TECNICIAN table.
 
Donald,
Make your cboTechnician combobox a 3 column combo, by adding a
TechnicianPhone and a TechnicianEmail column to your combo query.
On the AfterUpdate event of combo cboTechnician, use this code...
[TechPhone] = [cboTechnician].Column(1)
[TechEmail] = [cboTechnician].Column(2)
(combo box columns are numbered 0,1,2,3, etc..)
Whenever cboTechnician is Updated, the two text controls are updated also.
hth
Al Camp
 
Thanks,

That worked for the TechPhone. But for some reason TechEmail stays blank.

AlCamp said:
Donald,
Make your cboTechnician combobox a 3 column combo, by adding a
TechnicianPhone and a TechnicianEmail column to your combo query.
On the AfterUpdate event of combo cboTechnician, use this code...
[TechPhone] = [cboTechnician].Column(1)
[TechEmail] = [cboTechnician].Column(2)
(combo box columns are numbered 0,1,2,3, etc..)
Whenever cboTechnician is Updated, the two text controls are updated also.
hth
Al Camp

Donald said:
have a form with a few fields I want auto field. I would like to pull the
data from a table that I have set up. Right now im using this code in the
after update to fill in the field.

If Left(Me.Technician, 3) = "Don" Then Me.TECHNICIAN_PHONE = "354"
ElseIf Left(Me.Technician, 3) = "Bob" Then Me.TECHNICIAN_PHONE = "352"
ElseIf Left(Me.Technician, 3) = "Dan" Then Me.TECHNICIAN_PHONE = "354"
ElseIf Left(Me.Technician, 3) = "Phi" Then Me.TECHNICIAN_PHONE = "352"
End If

I have a table named "Technicians" that have both fields for
TECHNICIAN_Phone and TECHNICIAN_EMAIL. I would like those to be entered
into
the TECHNICIAN_PHONE and TECHNICIAN_EMAIL in the form. The TECHNICIAN is a
drop down box that selects a name from the TECNICIAN table.
 
Have you checked the RowSource and the ColumnCount of the ComboBox?

The ColumnCount needs to cover all Columns you want to use. For example,
the ColumnCount must be at least 3 in the posted code.

--
HTH
Van T. Dinh
MVP (Access)


Donald said:
Thanks,

That worked for the TechPhone. But for some reason TechEmail stays blank.

AlCamp said:
Donald,
Make your cboTechnician combobox a 3 column combo, by adding a
TechnicianPhone and a TechnicianEmail column to your combo query.
On the AfterUpdate event of combo cboTechnician, use this code...
[TechPhone] = [cboTechnician].Column(1)
[TechEmail] = [cboTechnician].Column(2)
(combo box columns are numbered 0,1,2,3, etc..)
Whenever cboTechnician is Updated, the two text controls are updated also.
hth
Al Camp

Donald said:
have a form with a few fields I want auto field. I would like to pull the
data from a table that I have set up. Right now im using this code in the
after update to fill in the field.

If Left(Me.Technician, 3) = "Don" Then Me.TECHNICIAN_PHONE = "354"
ElseIf Left(Me.Technician, 3) = "Bob" Then Me.TECHNICIAN_PHONE = "352"
ElseIf Left(Me.Technician, 3) = "Dan" Then Me.TECHNICIAN_PHONE = "354"
ElseIf Left(Me.Technician, 3) = "Phi" Then Me.TECHNICIAN_PHONE = "352"
End If

I have a table named "Technicians" that have both fields for
TECHNICIAN_Phone and TECHNICIAN_EMAIL. I would like those to be entered
into
the TECHNICIAN_PHONE and TECHNICIAN_EMAIL in the form. The TECHNICIAN is a
drop down box that selects a name from the TECNICIAN table.
 
Columncount fixed it. Thanks guys.

Van T. Dinh said:
Have you checked the RowSource and the ColumnCount of the ComboBox?

The ColumnCount needs to cover all Columns you want to use. For example,
the ColumnCount must be at least 3 in the posted code.

--
HTH
Van T. Dinh
MVP (Access)


Donald said:
Thanks,

That worked for the TechPhone. But for some reason TechEmail stays blank.

AlCamp said:
Donald,
Make your cboTechnician combobox a 3 column combo, by adding a
TechnicianPhone and a TechnicianEmail column to your combo query.
On the AfterUpdate event of combo cboTechnician, use this code...
[TechPhone] = [cboTechnician].Column(1)
[TechEmail] = [cboTechnician].Column(2)
(combo box columns are numbered 0,1,2,3, etc..)
Whenever cboTechnician is Updated, the two text controls are updated also.
hth
Al Camp

have a form with a few fields I want auto field. I would like to pull the
data from a table that I have set up. Right now im using this code in the
after update to fill in the field.

If Left(Me.Technician, 3) = "Don" Then Me.TECHNICIAN_PHONE = "354"
ElseIf Left(Me.Technician, 3) = "Bob" Then Me.TECHNICIAN_PHONE = "352"
ElseIf Left(Me.Technician, 3) = "Dan" Then Me.TECHNICIAN_PHONE = "354"
ElseIf Left(Me.Technician, 3) = "Phi" Then Me.TECHNICIAN_PHONE = "352"
End If

I have a table named "Technicians" that have both fields for
TECHNICIAN_Phone and TECHNICIAN_EMAIL. I would like those to be entered
into
the TECHNICIAN_PHONE and TECHNICIAN_EMAIL in the form. The TECHNICIAN is a
drop down box that selects a name from the TECNICIAN table.
 
Back
Top