Solved

case statement reserve word

Posted on 2006-11-09
9
290 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

758 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

22 Experts available now in Live!

Get 1:1 Help Now