1

I am building a form and having trouble with getting the DLookup to function correctly.

Here is what I have. I have a query which contains employee information relating to Profits and Loss. so things like name, salary, etc.

Now I am creating a form where I can see a listbox of my employees on the left and when I click on one of the entries in the listbox it populates a series of text boxes with the various values of the fields from that specific record.

I am using access 2007 I built a listbox off a query which contains all the fields that I want to get the data populated from. however I am having trouble configuing the Control source of the text boxes so that they will populate with that employee's data.

Could someone please help? Should I use a VBA onclick event instead or is there a way I can get the effect that I am looking for simply by modifying the Control source for the specific textboxes that I want to populate?

HansUp
  • 95,961
  • 11
  • 77
  • 135
Mr. Finn
  • 99
  • 3
  • 13

1 Answers1

0

"I built a listbox off a query which contains all the fields that I want to get the data populated from"

Since the listbox columns contain everything you need to populate the text boxes, use the list box's After Update event to load the text boxes.

Me.TextBox1.Value = Me.YourListBox.Column(0)
Me.TextBox2.Value = Me.YourListBox.Column(1)
Me.TextBox3.Value = Me.YourListBox.Column(2)

Notice the listbox column numbering starts from zero.

HansUp
  • 95,961
  • 11
  • 77
  • 135