TextBox/Table question

  • Thread starter Thread starter Onelson
  • Start date Start date
O

Onelson

Guest
I've just started learning Access for the most part, and hopefully this is the right place to ask this question.

I have a form where I would like the user to be able to add, update, and view some information all in the same place, based on the overall table primary key which populates a combo box with the appropriate values. The rest of the pieces of the form are all text boxes with an update button.

Now what I want to do but can't figure out how, is when the user selects an item from the combo box, search through the associated table, and fill the text boxes with the other fields from that table. For example, if the combo box held contact information and the user selected "Fred Flinstone", I would want to have the form search through the associated table (there being only 1 posible instance per name), and fill in the phone number/fax/etc text box values with the correct information for Fred Flinstone.

What is the best way to accomplish this?

Thanks in advance,
Owen
 
Code:
   Private Sub cboSelect_AfterUpdate()
   
   Dim strSearch As String

   'For text IDs
   strSearch = "[______ID] = " & Chr$(34) & Me![cboSelect] & Chr$(34)

   'For numeric IDs
   strSearch = "[______ID] = " & Me![cboSelect]

   'Find the record that matches the control
   Me.RecordsetClone.FindFirst strSearch
   Me.Bookmark = Me.RecordsetClone.Bookmark
fill in the blank with your PK

p.s. it's Flintstone (flint-stone). :)
 
Owen, First of all, Wazz is correct, it is "FlintStone", not "Flinstone".

Secondly, If I've understood correctly, your form is UNBOUND?
It's the combobox the has the "Associated Table"?

Wazz's code, is very effective for finding records through a bound Form.

But what you may want, is to populate Unbound fields with criteria from your combo box?

If so.

You can elaborate more on your combo box, by adding more fields to its rowsource.
cboName.RowSource = "SELECT pkID, txtName, txtAddress, txtPosition, txtSalary FROM tblEmployee"
cboName.ColumnWidth = "0in;1in;0in;0in;0in"

cboName_AfterUpdate()
Me.txtName = cboName.Column(1)
Me.txtAddress = cboName.Column(2)
Ma.txtPosition = cboName.Column(3)
...
 

Users who are viewing this thread

Back
Top Bottom