Tables Question

S

Scientific

Hello all,

I know that the following code returns an integer value, but is it possible
to return a text value instead? I tried using the Column() function to
return a text value but it doesn't seem to work.

Select Case Me.Whatever.Value
Case 1
blah blah blah

Case 2
blah blah blah
End Select

-S
 
J

John W. Vinson

Hello all,

I know that the following code returns an integer value, but is it possible
to return a text value instead? I tried using the Column() function to
return a text value but it doesn't seem to work.

Select Case Me.Whatever.Value
Case 1
blah blah blah

Case 2
blah blah blah
End Select

-S

I'm sure there is... but since I cannot see your database, and have no idea
whatsoever where this code is, where it's getting a number, what the "blah
blah blah" representes, what text you want to return, and even in what way the
code "returns an integer" (it doesn't), I have no idea how.

Give us a little help here please?
 
S

Scientific

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
 
J

John W. Vinson

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
 
S

Scientific

John, Mike Painter,

I found a solution reading another post. All I had to do was change one
thing which follows:

Changed:
Select Case Me.cboBadges.Value

To:
Select Case Me.cboBadges.Text

Now I can actually test for the text inside the table which doesn't change,
instead of a row value which does change as records are added or deleted.
Don't know if I am making sense here but it did the trick. Thank you both
for trying to read my mind :) And a bigger thanks for even responding to my
post. Your both awesome.

-S
 
J

John W. Vinson

John, Mike Painter,

I found a solution reading another post. All I had to do was change one
thing which follows:

Changed:
Select Case Me.cboBadges.Value

To:
Select Case Me.cboBadges.Text

Now I can actually test for the text inside the table which doesn't change,
instead of a row value which does change as records are added or deleted.

The Text property of a combo box control is what the user has TYPED and has
not been saved to the table.

In other words, what you're testing is *not* what's in the table and is *not*
something that doesn't change, but rather what's temporarily on the form and
*is* subject to change.

I hope you're not off track somehow!
 
S

Scientific

You were right about me being off the track. I had the wrong form open when
I was doing my tests. Oh well, back to the drawing board. I know I'm
missing something somewhere. Thanks for your input though!

-S
 
S

Scientific

Guys,

Sorry for not posting back sooner. I created a new database with new
controls and my original post has been answered. You were both right and the
Column(1) property returns what I was trying to get. Thanks a million both
of you :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top