Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old November 27th, 2004, 09:03 AM
ljungstrom ljungstrom is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 7 ljungstrom User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 32 sec
Reputation Power: 0
Question Using a variable in WHERE statement

Hi

I have a table in an Access DB, containing members and lessons and weeks.
Each members has at least one lesson per week.
Column namnes are recID, recName, recLesson, and the weeks (like w46, w47, w48 etc).

Now I would like the count the number of cancellations the members does for the weeks.

So I use this code, and it works just fine:

RS.Source = "SELECT Count(*) AS intTotal FROM tbl_lesson WHERE recLesson LIKE 'we 18.00' AND w48 LIKE 'C'"

So now to my problem, Iwould like to use a variable instead of the "w48". I have a CASE where I set the variable week
depending on current week.

So I want my code look like this instead:

RS.Source = "SELECT Count(*) AS intTotal FROM tbl_lesson WHERE recLesson LIKE 'we 18.00' AND week LIKE 'C'"

But, I cant get it to work :-(
(week works fine I use it when I display the lessons, it automatically pick the current week)
Any idea or suggestions on how to solve it?

Thanks in advance
/B
























Reply With Quote
  #2  
Old November 27th, 2004, 09:18 AM
ljungstrom ljungstrom is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 7 ljungstrom User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 32 sec
Reputation Power: 0
:-D... It is just great to write the problem down here..I just solved it like this

RS.Source = "SELECT Count(*) AS intTotal FROM tbl_lesson WHERE recLesson LIKE 'we 18.00' AND " & week & " LIKE 'C'"

Thanks anyhow, and I hope that someone else has use of it.
/B

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > Using a variable in WHERE statement


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT