Need help with Select Case Statement syntax.

G

GitarJake

Hello all,

How do I refer to a 'day' in a Select Statement? Please see the 3rd Case:

Select Case Time()
Case #8:30:00 AM# To #10:29:59 AM#
Me.txtService = "1st"
Case #10:30:00 AM# To #1:00:00 PM#
Me.txtService = "2nd"
Case Date() = Saturday
Me.txtService = "Sat"
End Select

TIA,

Jake
 
J

John Vinson

Hello all,

How do I refer to a 'day' in a Select Statement? Please see the 3rd Case:

Select Case Time()
Case #8:30:00 AM# To #10:29:59 AM#
Me.txtService = "1st"
Case #10:30:00 AM# To #1:00:00 PM#
Me.txtService = "2nd"
Case Date() = Saturday
Me.txtService = "Sat"
End Select

Try:

Case(Weekday(Date()) = vbSaturday
 
C

Chris

The TIME() function returns the current time. It does not
include the date in that.

You'll have to rework your Select statement to use Now()
instead.


Chris
 
J

John Vinson

Case(Weekday(Date()) = vbSaturday

Oops!

Should be

Case Weekday(Date) = vbSaturday

I had an *extra* paren, and the () after Date is optional in VBA (and
will be removed by the VBA editor) - it's required in a query.

You can also use

Case DatePart("w", Date) = vbSaturday
 
G

GitarJake

Hi John,

Thanks for taking the time to answer! :D

When I use your suggestion, Access complains of a missing parenthesis at the
end of the statement. When I provide the paren, Access changes the
statement to:

Case (Weekday(Date) = vbSaturday)

When I run this code, nothing happens. No errors, no nothin'.

It's Access 2000 on Win98. The code is behind a continuous subform and
txtService is on the subform.

Thanks,

Jake
 

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