if statment in case statement

I

iccsi

I would like to do something depends on option button user click in
the case statment like following:


Select Case MyTool

Case 1: if fmeMode = 1 then
Set qdTool = CurrentDb.QueryDefs("SP1 ")
elseif fmeMode = 2 then
Set qdTool = CurrentDb.QueryDefs("SP2")
end if

but I got compiled error.

I just wonder can I have if statment in the case statement?
If not, are there any work around?

Your information is great appreciated,
 
D

Dirk Goldgar

iccsi said:
I would like to do something depends on option button user click in
the case statment like following:


Select Case MyTool

Case 1: if fmeMode = 1 then
Set qdTool = CurrentDb.QueryDefs("SP1 ")
elseif fmeMode = 2 then
Set qdTool = CurrentDb.QueryDefs("SP2")
end if

but I got compiled error.

I just wonder can I have if statment in the case statement?
If not, are there any work around?


You can't use the single-line Case, because it's a multi-line If. Do this:

Select Case MyTool

Case 1
if fmeMode = 1 then
Set qdTool = CurrentDb.QueryDefs("SP1 ")
elseif fmeMode = 2 then
Set qdTool = CurrentDb.QueryDefs("SP2")
end if

Case 2
' ... etc.

End Select
 
I

iccsi

You can't use the single-line Case, because it's a multi-line If.  Do this:

    Select Case MyTool

        Case 1
            if fmeMode = 1 then
                Set qdTool = CurrentDb.QueryDefs("SP1 ")
            elseif fmeMode = 2 then
                Set qdTool = CurrentDb.QueryDefs("SP2")
            end if

        Case 2
            ' ... etc.

    End Select

--
Dirk Goldgar, MS Access MVPwww.datagnostics.com

(please reply to the newsgroup)- Hide quoted text -

- Show quoted text -

Thanks millions,
 

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