PC Review


Reply
Thread Tools Rate Thread

Case statement help

 
 
=?Utf-8?B?SkQ=?=
Guest
Posts: n/a
 
      7th Jun 2005
Looking for a hand in understanding case statements. Looked up MSFT examples
as well as some of the posts here, but it's not sinking in. I'm tyring to
create a case statement that evaluates the value of a combo box and sets the
value of other combo boxes depenending on whats in it. I'm lost, any help
would be appreciated.
I can do the same tasks with if then's, but it would be messy. New to
coding, any help would be really apprecaited.

Tried a couple variations of the following but it does not work.

Private Sub Combo1_AfterUpdate()
Dim verify as string
verify = me.combo1.value

Select Verify
Case1
verify ="ABC"

Case2
verify ="DEF"

End Select

Select Case Verify
Case1
combo2.value ="true"
combo3.value ="N/A"

Case2
combo2.value ="false"
combo3.value ="true"

End Select
End Sub
 
Reply With Quote
 
 
 
 
Ken Snell [MVP]
Guest
Posts: n/a
 
      7th Jun 2005
What is the value that would be in Verify?

Normal Case syntax:

Select Case NameOfControlOrVariable
Case "some value"
' code to do something when NameOfControlOrVariable = "some value"
Case "other value"
' code to do something when NameOfControlOrVariable = "other value"
End Select

--

Ken Snell
<MS ACCESS MVP>

"JD" <(E-Mail Removed)> wrote in message
news77608EC-01DA-45C8-B5A1-(E-Mail Removed)...
> Looking for a hand in understanding case statements. Looked up MSFT
> examples
> as well as some of the posts here, but it's not sinking in. I'm tyring to
> create a case statement that evaluates the value of a combo box and sets
> the
> value of other combo boxes depenending on whats in it. I'm lost, any help
> would be appreciated.
> I can do the same tasks with if then's, but it would be messy. New to
> coding, any help would be really apprecaited.
>
> Tried a couple variations of the following but it does not work.
>
> Private Sub Combo1_AfterUpdate()
> Dim verify as string
> verify = me.combo1.value
>
> Select Verify
> Case1
> verify ="ABC"
>
> Case2
> verify ="DEF"
>
> End Select
>
> Select Case Verify
> Case1
> combo2.value ="true"
> combo3.value ="N/A"
>
> Case2
> combo2.value ="false"
> combo3.value ="true"
>
> End Select
> End Sub



 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      7th Jun 2005
The Case statements need a space between the word Case and the value. The
value is an actual value, too, not a position.

Since your first SELECT CASE structure is resetting the value of the
variable verify to either ABC or DEF. Therefore, I'd expect the second
SELECT CASE structure to refer to values ABC and DEF:

Select Case Verify
Case "ABC"
me.combo2.value ="true"
me.combo3.value ="N/A"
Case "DEF"
me.combo2.value ="false"
me.combo3.value ="true"
End Select




--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"JD" <(E-Mail Removed)> wrote in message
news77608EC-01DA-45C8-B5A1-(E-Mail Removed)...
> Looking for a hand in understanding case statements. Looked up MSFT
> examples
> as well as some of the posts here, but it's not sinking in. I'm tyring to
> create a case statement that evaluates the value of a combo box and sets
> the
> value of other combo boxes depenending on whats in it. I'm lost, any help
> would be appreciated.
> I can do the same tasks with if then's, but it would be messy. New to
> coding, any help would be really apprecaited.
>
> Tried a couple variations of the following but it does not work.
>
> Private Sub Combo1_AfterUpdate()
> Dim verify as string
> verify = me.combo1.value
>
> Select Verify
> Case1
> verify ="ABC"
>
> Case2
> verify ="DEF"
>
> End Select
>
> Select Case Verify
> Case1
> combo2.value ="true"
> combo3.value ="N/A"
>
> Case2
> combo2.value ="false"
> combo3.value ="true"
>
> End Select
> End Sub



 
Reply With Quote
 
David C. Holley
Guest
Posts: n/a
 
      8th Jun 2005
The syntax appears to be correct in the 2nd example...

Select Case [expression/variable]
Case [value]
[code]
Case [value]
[code]
Case else
End Select

What exactly is happening that indicates that its not working?

JD wrote:
> Looking for a hand in understanding case statements. Looked up MSFT examples
> as well as some of the posts here, but it's not sinking in. I'm tyring to
> create a case statement that evaluates the value of a combo box and sets the
> value of other combo boxes depenending on whats in it. I'm lost, any help
> would be appreciated.
> I can do the same tasks with if then's, but it would be messy. New to
> coding, any help would be really apprecaited.
>
> Tried a couple variations of the following but it does not work.
>
> Private Sub Combo1_AfterUpdate()
> Dim verify as string
> verify = me.combo1.value
>
> Select Verify
> Case1
> verify ="ABC"
>
> Case2
> verify ="DEF"
>
> End Select
>
> Select Case Verify
> Case1
> combo2.value ="true"
> combo3.value ="N/A"
>
> Case2
> combo2.value ="false"
> combo3.value ="true"
>
> End Select
> End Sub

 
Reply With Quote
 
=?Utf-8?B?SkQ=?=
Guest
Posts: n/a
 
      8th Jun 2005
Ken/Doug/David,

Thanks for the help. I wound up changing the Case statment to follow Ken's
format. With a few changes, i was up and running. The previous code I was
using wouldn't error at runtime, however, the code didn't appear to do
anything. I.e, combo box values wouldn't change. I'm all set with my new
case statment and it works. I got rid of the variable verfiy and just called
the contorl name. Seem'd to do the trick. I appreciate your guys help!

JD





"David C. Holley" wrote:

> The syntax appears to be correct in the 2nd example...
>
> Select Case [expression/variable]
> Case [value]
> [code]
> Case [value]
> [code]
> Case else
> End Select
>
> What exactly is happening that indicates that its not working?
>
> JD wrote:
> > Looking for a hand in understanding case statements. Looked up MSFT examples
> > as well as some of the posts here, but it's not sinking in. I'm tyring to
> > create a case statement that evaluates the value of a combo box and sets the
> > value of other combo boxes depenending on whats in it. I'm lost, any help
> > would be appreciated.
> > I can do the same tasks with if then's, but it would be messy. New to
> > coding, any help would be really apprecaited.
> >
> > Tried a couple variations of the following but it does not work.
> >
> > Private Sub Combo1_AfterUpdate()
> > Dim verify as string
> > verify = me.combo1.value
> >
> > Select Verify
> > Case1
> > verify ="ABC"
> >
> > Case2
> > verify ="DEF"
> >
> > End Select
> >
> > Select Case Verify
> > Case1
> > combo2.value ="true"
> > combo3.value ="N/A"
> >
> > Case2
> > combo2.value ="false"
> > combo3.value ="true"
> >
> > End Select
> > End Sub

>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Case Statement Emma Microsoft Access 25 22nd Apr 2009 07:53 PM
IIf statement vs Select Case statement PaulDenver Microsoft Access Queries 4 6th Sep 2006 05:27 PM
IIf statement vs Select Case statement PaulDenver Microsoft Access Queries 1 4th Sep 2006 09:11 PM
Embedded IF statement in SELECT CASE statement =?Utf-8?B?S2lyayBQLg==?= Microsoft Access VBA Modules 1 3rd Mar 2005 05:45 PM
switch statement: Is it possible to include something like "Case var > 5" in a case statement? Juan Microsoft C# .NET 5 1st Feb 2005 05:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:31 AM.