Subroutine as control source

AnnaFoot

Registered User.
Local time
Today, 00:36
Joined
Dec 5, 2000
Messages
51
Hello,

Without getting too longwinded, i am having to produce a report which translates my client's personal shorthand method of noting the medication of a patient - they do have consistent shorthand for a given medication, but not a consistent order, or number of medications - into a description of the medication offered for the patient.

My current solution is to have a table with the shorthand for the medication and the actual description required on the report.

When the report is run, i have a nonvisible textbox control that has as its control source a subroutine which takes the shorthand list of medications and compares it one at a time to the 20 possible options, and then concatenates the required official descriptions, using blank lines etc, This long list is then written to another textbox, which is visible and can grow.

Essentially, it seems to work fine, it finds all the correct descriptions, it puts some of the textbox on the next page if needed, however, on closer inspection it does not always display what it should. Each time i generate the report, different patients work, and don't work. It isn't in the code (the correct number of medications are being recognised.) I think it must be in the formatting or printing events that i need to add something. If i print out a single page, it may or may not look the same as that page on the screen.

Any ideas, any thoughts on a different approach. (I've tried using the subroutine in the detail onformat event, and using the concatenated text to populate the caption for a label, however that would take the whole thing to the new page, rather than some on each, and i couldn't get the text boxes further down the report to move down the correct amount.)

I did get long winded after all - sorry

Anna
 
Anna,

I would think that it would be better to use a Public Function to do what
your subroutine currently does. Then you can call it from the query that
feeds your report.

Wayne
 
Wayne,
Thanks for the reply. I did half try this before, but got into trouble because i couldn't figure out how to pull the field i wanted to compare into the function. It appears in the query that drives the report, if i am running the function from within the query, how do i name the field in the function so that it pulls it from the query. Then, when the function has generated the long description, how do i write it back to the query?

Hope that makes sense!
Anna
 

Users who are viewing this thread

Back
Top Bottom