Ok, it's a bit complicated, but you asked!
I have a table that logs interaction with clients. So, the fields would be something like:
ID
ClientID
Date
Description
The description would be text such as "Client called to complain about..." or "Client purchased...", "Client returned product..." and so on including detail. The text in the log is generated by the program so the first few words will be very consistent.
I am trying to build what I am calling a "Client Browser". It's a treeview control that allows you to have an overall look at a client's history. So, the top node is the client's name, and then a child node for the client's purchases, and then another client node for the client's log.
The children nodes would consist of incidents from the log. I want to have the date of the incident and then a brief description of the interaction in the log such as:
- 11/4/07 Client Complaint
- 05/19/08 Purchase
- 01/11/08 Return
That way you see a great overview of the log.
My design is to create a function that gets passed the ID of each description entry related to this client in the log. The function examines the log entry and passes back an appropriate string. So, if the entry said "Client called to complain that his widget was the wrong colour", the function uses a Like "Client called to complain*" to return the string "Client complaint". Of course if I have about 8 possible strings that the function could return, then a Select Case would be the best approach.
There are other approaches but I'm not certain what the best would be. It sounds like a Select is out, so a bunch of Ifs may be in order, or to write a query with nested IIfs may be possible but would be ugly to read and a nightmare to debug.
Any thoughts?
SHADOW