By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,327 Members | 1,805 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,327 IT Pros & Developers. It's quick & easy.

Question on using cases, and possibily string comparison...

P: 9
This should be an easy question. My code below works, but I'm realising that using a seperate case for each "cabtype" will end up making my code very bulky, and right now its over 64k, making it too big. This code checks [cbo_cabtype] from a form in my database, and depending on the cabtype it will execute different code.

frmcables.[cbo_cabtype].SetFocus
Select Case frmcables.[cbo_cabtype]
Case "2C1"
With frmcables
'
'
' My code
'
'
End With

Basically, I would like to check if the "cabtype" I want is one of many different ones, instead of just one (2C1 in the above code). So I'd like to have some code similar to the code below. Keep in mind that this code does not work.

frmcables.[cbo_cabtype].SetFocus
Select Case frmcables.[cbo_cabtype]
Case "2C1" or "2C2" or "2C3"
With frmcables
'
'
' My code
'
'
End With

When I try this code I get runtime error 13 (type mismatch). Any way that I can make this code work? I'd just make a whole bunch of different cases, one for each "cabtype", but doing this has made my code too large.

Any suggestions?

Thanks

Ian
Aug 6 '08 #1
Share this Question
Share on Google+
3 Replies


missinglinq
Expert 2.5K+
P: 3,532
Just place a comma between then:

Case "2C1", "2C2", "2C3"


You might want to take a look at this post. It presents a number of ways for working with Cases:

Understanding the Select Case Statement

Linq ;0)>
Aug 6 '08 #2

NeoPa
Expert Mod 15k+
P: 31,661
Nice link Linq ;)

That should answer all the questions, but if you need more help feel free to post.

Welcome to Bytes!
Aug 6 '08 #3

P: 9
Thanks!!! Exactly what I was looking for.
Aug 7 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.