Structured Conditional Statements

message from =?Utf-8?B?SmVycnkgVy4=?= on 1 Jun 2004
Am having trouble with the correct syntax for "If...Then" and "Select Case" statements. Am not using correct punctuation somewhere. Example: Select Case [Usage] Case Is <=0 (0) Case Is >=90 (90) Case Else [Usage]. Any suggestions?
 
Van T. Dinh replied to =?Utf-8?B?SmVycnkgVy4=?= on 1 Jun 2004
Select Case [Usage]
Case Is <=0
'{statements}

Case Is >=90
'{statements}

Case Else
'{statements}
End Select

HTH
Van T. Dinh
MVP (Access)

for "If...Then" and "Select Case" statements. Am not
using correct punctuation somewhere. Example: Select Case
[Usage] Case Is <=0 (0) Case Is >=90 (90) Case Else
[Usage]. Any suggestions?
 
John Vinson replied to =?Utf-8?B?SmVycnkgVy4=?= on 01 Jun 2004
In VBA it's all on separate lines:

Select Case [Usage]
Case Is <=0
answer = 0
Case Is >=90
answer = 90
Case Else
answer = [Usage]
End Select

If you're talking about using CASE in a Query, unfortunately it is not
supported in the Access dialect of SQL. Neither is If... Then. You can
use the IIF() or Switch() VBA functions - in a query, you could use

Answer: Switch([Usage] <= 0, 0, [Usage] >= 90, 90, True, [Usage])

John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public
 

Archived message: Structured Conditional Statements (Microsoft Access Forms)