Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SWITCH function to Group Values

Status
Not open for further replies.

CHTHOMAS

Programmer
Jun 16, 1999
106
0
0
AE
Visit site
I have a table field "kstsrt" with values like A00,A01,A02.......A99.
I want to create a report and in that I Want some of the values to appear as grouped. ie say A11 and A13 should appear as A11+A13. similarly A71,A72,A73 should appear as A71+A72+A73. The rest of the values should appear as it is. I tried creating a query based on the table and then using SWITCH FUNCTION. But am not getting the results correctly. Can anyone guide me?

I tried something similar below, the grouped values are appearing correctly, but getting #Error for the non grouped values

Switch([kstsrt]="A11","A11+A13","A13","A11+A13","A71","A71+A72+A73","A72","A71+A72+A73","A73","A71+A72+A73",True,[kstsrt])



Regards,

Charley
 
I take it your want the fields to be displayed as if hooked together. Use the Ampersand instead of the + sign to cancatenate the fields together.

From ACCESS Help:
Used to force string concatenation of two expressions.
Syntax
result = expression1 & expression2

Bob Scriver

Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Sorry, I missed the real problem. Your expression is looking for a field name it seems when your have to look at the Control Source to see what field/query name is present:

Current:
Switch([kstsrt]="A11","A11+A13", . . .
Should be:
Switch([kstsrt].ControlSource = "A11",. ..

Bob Scriver

Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Also, remove the double-quotes from around the cancatenation expressions.

Switch([kstsrt].controlsource ="A11",A11+A13,"A13",A11+A13,. . .

Otherwise, they would be treated as a string rather than values being cancatenated together for display.

Bob Scriver

Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top