Change textbox according to result in Combo box.

J355Y1

Registered User.
Local time
Tomorrow, 03:05
Joined
Jan 31, 2011
Messages
12
Hi,
I have a form which has both a combo box and a textbox, the combo box displays the names of Students at a swimming carnival except i have joined the first name and last name columns together so the combo box displays both eg. "Bill Smith"
Now my textbox is suppose to be the students gender and the default value is B/G but i need it to display either G or B according to the sex of the student selected in the combo box.
The combo box is linked to the table "Students" which has the following fields; RegNo, FirstName, LastName, Sex and DOB and the text box is linked to nothing at the moment.

How do i make the textbox display the gender, either B or G according to the student selected in the combo box??

Thanks!
 
Welcome to the forum.

So long as gender in one of the fields that makes up the Row source of your combo box (it doesn't have to be visible), you can use the following as the Control Source for you Gender text box;
Code:
=Me.YourComboName.Column([B][COLOR="Red"]x[/COLOR][/B])
Where x represents the column that hold the Gender data. Remember that the columns of a combo or list box are zero referenced ie. the first column (usually hidden, and often the bound column) is column zero the next column one and so on.
 
Thank you for your help,
I tried what you said but now instead of displaying B/G, B or G depending on what is selected it only shows "#Name?" I do not know what the problem is? My combo box says unbound, could that be why? I am quiet new to this.

Thanks
 
If you use the AfterUpdate Event of the combo box use the following code

Me.Gender = Me.ComboBox.Column(x)

Code shown or brevity only use your own field names and column numbers
 
Ok so i tired that code and when i change the record in the combo box the gender textbox changed but it just changed to blank. How would i get it to change to either G or B according to the gender of the selected record?

Thanks!
 
Have you made sure to set the column count property for the combo box?

Column Count (needs to be 5 in your case)
 
No i had not set the column count, but i changed it and now it works so thanks very much!!!
 
@boblarson - Could you please explain to me why it had to be 5?
 

Users who are viewing this thread

Back
Top Bottom