Command Button to populate locked text boxes?

M

Mike

Hey all! I have a form in which has multiple text boxes containing salesman
information. I've placed a combo box on that form to display the salesman
IDnumber, LastName, FirstName, and MiddleInitial. How can I use the textbox
to select the salesman I want and in when doing so, have the system populate
all the remaining textboxes on the form? Does this make sense?

Mike
 
B

Beetle

If the text boxes are *bound* to table fields, and assuming that one of
them is bound to the IDnumber field, then it's just a matter of finding
the matching record. For this method you would use an *unbound* combo
box, probably in the form header. In the After Update event of your
combo box you would code;

With Me.RecordsetClone
.FindFirst "[IDNumber]=" & Me.MyCombo
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With

If the text boxes on your form are *unbound*, then you could add
all the necessary fields to the rowsource of your combo box (make
the width 0 if you don't want the users to see the columns) and
refer to them using the Column method like;

Me![SomeTextBox] = Me![MyCombo].Column(2)
Me![SomeOtherTextBox] = Me![MyCombo].Column(3)
etc., etc.
 
P

pietlinden

Hey all!  I have a form in which has multiple text boxes containing salesman
information.  I've placed a combo box on that form to display the salesman
IDnumber, LastName, FirstName, and MiddleInitial.  How can I use the textbox
to select the salesman I want and in when doing so, have the system populate
all the remaining textboxes on the form?  Does this make sense?

Mike

push or pull methods.
in the after update event of the combobox, you could set the value of
each to a column in your combobox.

Say
Column#, Field
0, IDNumber
1, LastName
2, FirstName
3, Middleinitial

Then the textbox for LastName would have as it's controlsource
=cboPerson.Column(1)
and so on.

If you go the other way, you have to write code to scatter the values.

Me.txtFirstName=cboPerson.Column(2)
Me.txtLastName=cboPerson.Column(1)
etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top