Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What's wrong with this IF statement? 1

Status
Not open for further replies.

ychousa

MIS
Jun 11, 2003
82
US
Hi.

I have 2 txtfields to generate an ID in my form, but they are not working.

Here's the code:

Private Sub SSpaceH_AfterUpdate()
Dim SSpaceW As String, SSpaceH As String

SSpaceW = Me!SSpaceW
SSpaceH = Me!SSpaceH

Select Case (SSpaceW And SSpaceH)
Case ("10" And "10"): Me![SSpaceType] = "1010"
Case ("10" And "20"): Me![SSpaceType] = "1020"
Case ("10" And "15"): Me![SSpaceType] = "1015"
Case ("15" And "10"): Me![SSpaceType] = "1510"
Case ("20" And "10"): Me![SSpaceType] = "2010"
Case ("20" And "20"): Me![SSpaceType] = "2020"
End Select
End Sub

SSpaceW, SSpaceH, SSpaceType are all text fields. It works with some sets but not all of them.

For example, it works with (10 And 10), (10 and 20), (20 and 20).

What is wrong with this IF statement?

 
Duh, just for a start, what "If" statement?

"It's got to be the going,
not the getting there that's good!"
-Harry Chapin
 
Hmm... I've not used multiple values with the Select Case statement before, but I suspect the AND operator is fouling the works. Anyway, it seems unnecessarily complicated. Why not just concatenate the strings?

Code:
Me![SSpaceType] = Me![SSpaceW] & Me![SSpaceH]

You can, of course, test for valid values in the fields before concatenating...

HTH

Ken S.
 
Hi, Ken.

Thanks for your comments.

I tried to use Case statement for some reason, but your're right. It's too complicated and maybe not worth trying it.

I would go for your suggestion.

Thanks..

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top