Field Types: Text, Number,...Code?

Randomblink

The Irreverent Reverend
Local time
Today, 14:57
Joined
Jul 23, 2001
Messages
279
Not sure where to start...

I have records that need to be handled / coded specially...
In other words...

Let's call this my OrderDatabase.

Let's say I have a form, we will call it: OrderForm

When I am filling in the order for a customer, if I pull up customer ABC, I want code to run in the background that alters the Tax AND Highlights the textbox with their Company / Ordering Name in it. Or let's say I select Item XYZ, I need to have a MSGBOX pop up to alert me that this item has special paperwork to process with it AND I want it to Register the customer who is ordering it with a special Discount ID# in their notes field...

Now these exact examples are false.
I know that I could run select case statements out the whazoo to do the same thing. I could even manipulate some text fields to do something similar. But I want to have a string of code, function, or whatever that is associated with EACH record...maybe even two fields...although if I could create functions in the field that would be just as good....

Now then...
IF (and I mean IF) I cannot put a block of code in a field and run it whenever that code is pulled up with the record it is attached to...then MAYBE, I could call a function when that record is selected by putting the function name in a field and calling it whenever the record is pulled up.

For instance...

I create my Item Table and it has an extra field in it, called CODE...
As I put in each item, I add something like: Call ThisFunction(ThisArg, ThatArg)
Then, whenever that item is pulled up, it calls ThisFunction utilizing ThisArg and ThatArg as arguments...

Can someone help me...?

Thanks in advance...
 
No Answer?

Did I ask a stupid question?
A dumb question?
Or was I not clear in my asking?
Help me please!

ack!
 
Ah...

Sorry then...
Thanks for the help...
 
What you are asking to do is not impossible but you open yourself to a nightmare of maintenance. I'll suggest a workaround for you that MIGHT (repeat MIGHT) be a practical and reasonable approach to what you asked....

You have a complex set of rules that apply differently to different elements of the same table. If EVERY ENTRY IS DIFFERENT, you are pretty much screwed. However, if you can break all entries down into categories of treatment that differ only in a couple of numeric parameters per category, then consider this:

Write special processing routines such as you have described, where category 0 means - everything is standard. Category 1 means - special tax rules. Category 2 means - special paperwork. Etc. etc. AND attempt to isolate parameters from processing specialties.

OK, now, in the tables, add fields corresponding to processing styles. Add fields corresponding to the greatest number of parameters you need for any one case.

Now, under the form, where you have this processing requirement, place some code at the point where you would normally do this processing. Use a Select Case statement to dispatch to the handler for this category. ONLY WITHIN THE CATEGORY CODE, refer to the possible parameters for that particular category.

This processing is extensible based on the number of categories you require and by the degree to which you can isolate parameters vs. styles of processing. I would hope that you would be able to break this down to a manageable number of options plus the appropriate parameters. In any case, whenever you come up with a new style, you have to add code to the elements of the Select Case statement, but other than that, all you need is a way to indicate the processing style.

The style could be part of a combo box in which the code number field is hidden but stored in the record. Then you could name or describe the style as column 2 of a lookup table. Now, what you do beyond that depends on details I would prefer to avoid. But the idea is, keep it data-driven by all means. But rather than write code in a memo field, STORE a code number that drives your processing using more traditional methods of data dispatching.
 

Users who are viewing this thread

Back
Top Bottom