Solved

case statement reserve word

Posted on 2006-11-09
9
291 Views
Last Modified: 2010-04-30
hi,

Please assist how can we use the case statement with the correct syntax, i've been having problems with reserve word?

    strRequest = "Select timevalue(datetime) as [DateTime], " & _
    " [case when 0=0 then 1 end] as [aaa] " & _
    " From [Mytable$]  " & _
    " group by timevalue(datetime);"

error returned "no value given for one or more required parameter."

Thanks.
0
Comment
Question by:FrankPorter
9 Comments
 
LVL 13

Assisted Solution

by:rettiseert
rettiseert earned 100 total points
ID: 17906752
what db are your using?

in access you can use

Switch( var=val, 1, var2=val2, 2 ...)
0
 

Author Comment

by:FrankPorter
ID: 17906771
msexcel
0
 
LVL 15

Assisted Solution

by:cquinn
cquinn earned 100 total points
ID: 17906790
Why are you using a Case staement?  0=0 will always be true, so 1 would always be expected as the result, so just set it explicitly

   strRequest = "Select timevalue(datetime) as [DateTime], " & _
    " 1 as [aaa] " & _
    " From [Mytable$]  " & _
    " group by timevalue(datetime);"
0
 

Author Comment

by:FrankPorter
ID: 17906855
cquinn,

It was for demonstration.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 11

Accepted Solution

by:
Dany Balian earned 300 total points
ID: 17907463
select case when field=value then 1 else 0 end as expr1, field, value from table group by field
0
 

Author Comment

by:FrankPorter
ID: 17907612
mrdany,

vb returned:
error returned "no value given for one or more required parameter."
0
 
LVL 11

Expert Comment

by:Dany Balian
ID: 17907798
well i need the field names... my fields were fictional... here's a good sql:

select case when parentcategory=category then 'main category' else 'sub category' end as categorytype,
category, parentcategory from categories group by category, parentcategory

can u give me ur sql, i can see what's wrong with it??

cheers
0
 

Author Comment

by:FrankPorter
ID: 17907813
this is the actual sql, i tried using the most basic. I'm using Ms Excel as database and VB as interface.

strRequest = "Select " & _
    " [case when 0=0 then 1 end] as [aaa] " & _
    " From [Mytable$] ; " 
.Open strRequest
0
 
LVL 11

Expert Comment

by:Dany Balian
ID: 17908363
i didnt get it.. does it work or not??

i tried it here, it's not working... i'm looking nito it..

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now