Auto-populate text boxes based on a query

  • Thread starter Thread starter Scott
  • Start date Start date
S

Scott

Hello,

I am a vb novice, so bear with me. I have a form for HR Partners in
my company to request new positions be built for the organizations
they support. About half of the information on each record can be
assumed based on the Organization for which the request is being
generated (ie. HR Partner, Org Executive, Financial Controller,
etc.). I am trying to write vb that will, upon selection of an
Organization from a combobox, auto-populate these fields in the form
with the information corresponding to that Organization. My
assumption is that I should be able to query for distinct
organizations and their corresponding data elements, then set the
textboxes' controlsources to these fields based on the value selected
in the 'Organization' combobox.

I hope that made sense. Any thoughts? Am I even in the ballpark?
 
You can either put code in the After_Update Event of the combo box similar to
this
TextBoxName = DLookUp("[FieldName]","Organisations Table","[FieldInTable] =
" & [ComboBoxName])
This line assumes that the value in the combo box and in the Organisations
table is numeric. If it is text then use
TextBoxName = DLookUp("[FieldName]","Organisations Table","[FieldInTable] =
'" & [ComboBoxName] & "'")
Repeat for other TextBoxNames

Alternatively you can set the control source property of the textboxes to
=DLookUp("[FieldName]","Organisations Table","[FieldInTable] = " &
[ComboBoxName])
or
=DLookUp("[FieldName]","Organisations Table","[FieldInTable] = '" &
[ComboBoxName] & "'")
 
You can either put code in the After_Update Event of the combo box similar to
this
TextBoxName = DLookUp("[FieldName]","Organisations Table","[FieldInTable] =
" & [ComboBoxName])
This line assumes that the value in the combo box and in the Organisations
table is numeric. If it is text then use
TextBoxName = DLookUp("[FieldName]","Organisations Table","[FieldInTable] =
'" & [ComboBoxName] & "'")
Repeat for other TextBoxNames

Alternatively you can set the control source property of the textboxes to
=DLookUp("[FieldName]","Organisations Table","[FieldInTable] = " &
[ComboBoxName])
or
=DLookUp("[FieldName]","Organisations Table","[FieldInTable] = '" &
[ComboBoxName] & "'")



Scott said:
I am a vb novice, so bear with me.  I have a form for HR Partners in
my company to request new positions be built for the organizations
they support.  About half of the information on each record can be
assumed based on the Organization for which the request is being
generated (ie. HR Partner, Org Executive, Financial Controller,
etc.).  I am trying to write vb that will, upon selection of an
Organization from a combobox, auto-populate these fields in the form
with the information corresponding to that Organization.  My
assumption is that I should be able to query for distinct
organizations and their corresponding data elements, then set the
textboxes' controlsources to these fields based on the value selected
in the 'Organization' combobox.
I hope that made sense.  Any thoughts?  Am I even in the ballpark?-Hide quoted text -

- Show quoted text -

Thanks a bunch Dennis! It worked perfectly.
 
Back
Top