Jamie S
Jamie S

Reputation: 75

Populate Text Boxes with Combo Box

I cannot get the data from the Combo Box to update the Text Boxes on my form, I'm hoping you can help!

Combo Box Code:

SELECT Employees.ID, Employees.LastName, Employees.FirstName, Employees.Title
FROM Employees;

After Update Event Code:

Private Sub cboNames_AfterUpdate()
  Me.txtLastName = Me![cboNames].Column(1)
  Me.txtFirstName = Me![cboNames].Column(2)
  Me.txtTitle = Me![cboNames].Column(3)
End Sub

All Control Sources seem to match up. Is there some little thing I'm doing wrong or should look for?

This is where I'm getting my info: http://support.microsoft.com/kb/319482

I've been trying for hours and hours... got it to work once, didn't save that file, haven't been able to get it working since, hate my life ;)

Please let me know if you need any other information!


EDIT: It works ONLY when it's been created from scratch... if I close the database and re-open it, it no-longer populates the fields. Anybody seen that before?

Upvotes: 0

Views: 1041

Answers (2)

Jamie S
Jamie S

Reputation: 75

The problem was Security settings. "Disable all macros with notification" wasn't actually notifying me of anything... I changed it to "Enable all macros" and it works perfect!!

Thank you for your help, @TheRedOne!! ...now if I can only get my six-plus hours back.

Upvotes: 0

TheRedOne
TheRedOne

Reputation: 165

I think you need to specify the row as well as the postition in that row. You have not specified the problem you are having exactly. Try this, and see if it helps:

Private Sub cboNames_AfterUpdate()
Me.txtLastName = Me![cboNames].Column(1,0)
Me.txtFirstName = Me![cboNames].Column(2,0)
Me.txtTitle = Me![cboNames].Column(3,0)
End Sub

If not, then please be more specific as to the problem you are having :-) Hope I can help

Upvotes: 1

Related Questions