VBA Combo Box

JMarcus

Registered User.
Local time
Today, 13:15
Joined
Mar 30, 2016
Messages
89
Im having a problem calling up the 4th column from a combo box to auto populate the field. Any restrictions, it is a date field as I can get text into the box?

Here is the code added to the event on change of the SQL combo box:
Private Sub Combo106_Change()
Me.FName.Value = Me.Combo106.Column(2)
Me.LName.Value = Me.Combo106.Column(1)
Me.TxtHICN.Value = Me.Combo106.Column(3)
Me.txtDate.Value = Me.Combo106.Column(4)


End Sub

Any help would be great.
 
Just a simplification suggestion: Using .Value on the left-hand side of an expression is redundant as .Value is the default choice for anything that HAS a value.

Now, here is the real question... what is in column 0? Columns in combo boxes number starting from 0, not from 1. Do you have 5 columns in the box (0,1,2,3,4 ?)
 
Yes, Column 0 is accounted for. I have the right corresponding columns. It is column 4 for a date x/xx/xxxx which is giving me a problem and I dont know why.
 
Any ideas? Ive been struggling with this as it looks like there may be a simple solution?
 
Ive tried everything. It might have something to do with it being a date format xx/xx/xxxx but not sure how to handle it. I know it has the correct columns.
 
maybe...
Me.txtDate = CDate(Me.Combo106.Column(4))
 
Thanks so much for response. Ill give it a try in the morning - it may work. I love this forum - everyone is so helpful.!
 
I tried it but it didnt work. Gave me Run-time error '94' Invalid use of null
 
I found the solution after many hours if you can believe it. It was the property setting in the cmombo box which needed to be changed from 3 to 4. Thanks to arnelgp and Gizmo for the posts.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom