Populate text boxes from a combo box query

_JSincliar

Registered User.
Local time
Today, 00:35
Joined
Dec 9, 2009
Messages
16
I have a combo box that is based off a query returning 5 columns. The first column is the row source of the combo box and I want to use the other 4 to populate 4 text boxes on the AfterUpdate event of the combo box.

The second columns' text box fills properley, however the others do not. The code shows the remaining columns values are null. However, when I run the query, it brings up the proper information, and not null fields.

This is the query:
SELECT tblUsers.UID, tblUsers.FirstName, tblUsers.LastName, tblUsers.Grade, tblUsers.TabletSerialNo
FROM tblUsers;

And this is the vba:
Me.txtFirstName = Me.cboStudentID.Column(1)
Me.txtLastName = Me.cboStudentID.Column(2)
Me.txtGrade = Me.cboStudentID.Column(3)
Me.txtSerialNo = Me.cboStudentID.Column(4)

Any insight would be appreciated

Thanks,
Jonathan Sinclair
 
Make sure the COLUMN COUNT property on your combo box is set appropriately.
 
Make sure the COLUMN COUNT property on your combo box is set appropriately.

Thanks, that worked great. The remaining text boxes populate when a selection is made.
Now whenever I open the combo box, it lists the the columns as part of the drop down. Is there a way to hide those columns and show only the first, and still have the text boxes populate? Although that's more of an asthetics thing since it does what I wanted it to do.

Thanks again,
Jonathan Sinclair
 
Set the COLUMN WIDTHS property for the columns you don't want to show to 0".

So, like this (example, if you want the first column but not the other 4 to show):

1";0";0";0";0"

or if you wanted the third column to show it would be:

0";0";1";0";0"
 
Set the COLUMN WIDTHS property for the columns you don't want to show to 0".

So, like this (example, if you want the first column but not the other 4 to show):

1";0";0";0";0"

or if you wanted the third column to show it would be:

0";0";1";0";0"

That did the trick,
Much appreciated.

Jonathan Sinclair
 

Users who are viewing this thread

Back
Top Bottom