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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple values in database field

Status
Not open for further replies.

MadCatmk2

Programmer
Oct 3, 2003
145
GB
Crystal Version: 9.0
Database: MSAccess

Hi all

Hopefully someone will be able to help me with this so here goes.

I have a database with that outlines contacts made by staff members to patients. One of the fields in the database relates to interventions. the data in the field is one or more 3 letter codes. Each code relates to another table {community_interventions} where the code and related description is located.

The problem i have is that i need to be able to take each of the three letter codes and get the descriptions from {community_interventions}.

I can split up the codes into an array, is there a way that each of the values in the array can be searched for in the
{community_interventions} table and displayed.

Hope this makes sense. Any help at all will be most appreciated.

Thanks
 
Hi again

I have possible found a way to do this and would like some advice on whether it seems like a viable way of doing it.

I have the following function in the details section of the report:

Code:
stringvar temp;
stringvar array InterArray;
stringvar temp2 := "";
numbervar i;

temp := replace(Replace({CONTACTS.INTERVENTIONS}, chr(13),""),chr(10)," ");

InterArray := split(temp, " ");
//temp

for i := 1 to Ubound(InterArray) do
(
if InterArray[i] = {COMMUNITY_INTERVENTIONS.Code} then
//temp2 := temp2 & " " & i;
temp2 := temp2 & chr(13) &
{COMMUNITY_INTERVENTIONS.Description};
);

temp2

This i was hoping would run the for loop and output all descriptions of the interventions from the codes stored in the array. I realise that this now will not work.

The idea that i have now is that i could use the array that is created here and share it. Once shared i can then access the array from a subreport which has the {community_interventions} as its database. I should be able to use a record selection to show only record in that database that are in the shared array.

I hope i've explained this ok. I'd appreciate comments on if this seems like a good idea.

Thanks again
 
Having difficulties with the shared array variable now. I have a formula @interventionsArray which declares the shared array InterArray and sets it to the value of the particular record that it is on. The only problem is that i keep getting the error that "The result of a formula cannot be an array"

Could somebody let me know how i should be declaring this array so that i can pass it to my subreport for use in the record selection formula.

Thanks
 
Hey MadCatmk2,

Looks like you're doing a pretty good job of keeping this conversation going all on your lonesome.

"The result of a formula cannot be an array" is basically a complaint that the formula display is going to end up being an array. You can usually get around this by ending the formula with some distraction code, like " ".

Naith
 
Naith.

Thanks for getting back to me. I managed to get the problem resolved, as you said it required something at the end of the formula so i added a true statement and this got round that. I managed to get the shared variable passed to the sub report and its all working hunky dory. Thanks for your reply. And i apologise for the amount of replies from myself, its just as soon as i post one question then another couple of problems seem to arise.

Its all good now :eek:)

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top