John,
The control named cboBadges is linked to a table named BadgeTypes which
represent the kinds of badges employees recieve. It worked just fine until I
added some badge types to the table and deleted some others. Now that the
record order has changed, the case tests are all screwed up. I thought it
would be better to test for a text string instead of a record number.
Problem is, when I tried using the Column() function it wouldn't work for me.
Any suggestions!
Public Function GetBadgeType()
Select Case Me.cboBadges.Value
Case 1 'Contrator badge
Me.imgBadge.Picture = "C:\Cobbham\Contractor.jpg"
Case 2 'Employee badge
Me.imgBadge.Picture = "C:\Cobbham\Employee.jpg"
Case 3 'Escort Required badge
Me.imgBadge.Picture = "C:\Cobbham\EscortReq.jpg"
End Select
End Function
Again: *WE CANNOT SEE YOUR DATABASE* nor can we read your mind.
You say "the column() property wouldn't work" but you don't say in what WAY it
doesn't work. One common problem is that the Column() property is zero based -
so if you want to see the second column in the combo's rowsource query you
need to use Column(1) (rather than your normal instinct to say Column(2),
which would be the THIRD column).
What is the Rowsource of cboBadges? Please open it in SQL view and post the
SQL text here.
What are the contents of that table now? What are the datatypes?
Might you consider actually storing the path and filename for the picture in
the combo's rowsource table? If you do so you don't need a Case at all; if you
(say) put the filename in the third column of the query (and set the
ColumnCount to 3) your code could be put into the AfterUpdate event of the
combo box:
Private Sub cboBadges_AfterUpdate()
Me!imgBadge.Picture = Me!cboBadges.Column(2)
End Sub