SQL Server Reporting Services Switch Statement

  mackaycc 17:50 06 Jun 2005

Hi All, I'm trying to put a switch statement into a report but am struggling to get the correct syntax for it. Does anyone know of a good site which could provide me with it or do you know what the correct structure would be?

Many thanks in advance.

  Access genu 19:45 06 Jun 2005

what do you mean by a switch statement? I have never come across it.

  mackaycc 22:00 06 Jun 2005

Instead of using nested if statements I'm trying to use the switch{case:} etc. statement. Part of it is working but for some results it throws up exceptions. I was looking for an easy reference as to how the switch statement should be written in reporting services.

  Access genu 22:14 06 Jun 2005

if you mean SQL CASE statement then try the microsoft knowledge base

click here

  mackaycc 02:38 07 Jun 2005

It's not SQL that I need. I need to know what syntax to use for the case statement when using it as an argument for formatting the page.

  Rand Al Thor 09:03 07 Jun 2005

I havn't used the switch function myself, but this is from the help file.

Evaluates a list of expressions and returns a Variant value or an expression associated with the first expression in the list that is True.


Switch(expr-1, value-1[, expr-2, value-2 … [, expr-n,value-n]])

Normally, I would do any formatting in a report using the On Format event. Not sure how it would work in SQL though. Anyhow, here is the method I would use. In the On Format event of the Detail section of the report place the case statements.

I use the tag property of the control to identify each control. I use this code to change the foreground colour of the control, depending on the test.

Hope this helps

Dim ctl As Control
Const vbRED = 255

For Each ctl In Me.Section(acDetail).Controls

Select Case ctl.Tag

Case "Tag Name"
'Case test here

Case "Tag Name"
'Case test here

End Select

Next ctl

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

Fujitsu Lifebook P727 laptop review

Converse's new logo: the trainer brand looks to its heritage for a fresh identity

Mac power user tips and hidden tricks

Comment lancer Windows 10 en mode sans échec ?