Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Hyukevain
Yak Posting Veteran
66 Posts |
Posted - 2004-09-28 : 06:52:41
|
Hi,I'm making an access application that can call function by their name.My application must be able to call a procedure by name, for instance, if I have procedure named "Test" then I must call the procedure by name such as call "Test", not call Test.My purpose is because every client of our company have different report layout which make us made different function for each of them.I can use case when function to choose which function gonna be run for this client, but that's not the effective way. If we have another new client then we must add another case in my function.Is that possible to choose which function will run by state their name ? I mean, I save the function name in my config file and every time my program load, it will read the config file and when call the function, my application just call the function name without using case when function anymore (more simpler and less code that need to change)exampleI have 3 function to show a report-Function viewLtr-Function viewUS-Function viewLtrPotraitIf the config file stated "viewLtr", then it will call function viewLtr, and so on.My function maybe can be more than 3 type in the future, so rather than I use parameter, can I just use the name ?Thank's for your time, any suggestion would be appriciate.Regards,Mike |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-09-28 : 09:02:45
|
why have 3 functions? why not have 1 function that accepts a parameter? If 3 different functions are doing the exact same thing, only varying by a minor detail here and there (i.e, Printing versus Previewing or Landscape vs Portrait), then they probably should all be the same function.I'm not sure what you are tyring to do here, but I'm willing to bet you are making things way more complicated than you need to.- Jeff |
 |
|
Hyukevain
Yak Posting Veteran
66 Posts |
Posted - 2004-09-28 : 13:11:35
|
1 function with parameterize variable only gonna lead you to "select case" function and we try to avoid this thing (this gonna make you have to change the procedure every time something new come up than not match with your old procedure). What we want to do is whenever you have new requirement for the procedure (this will not apply in calling report only, but will apply in another procedure, such as calculate procedure) we just add another procedure that match with our need without change the old one, and what procedure we want to use, just read the procedure name from the config file and call the procedure with that name, in other way, we want to call which procedure we want to use dynamically without use any parameter to determine which procedure we want to use. (Tried not to change the old source code)Thank's for your response Jeff, I really appreciate that, and any other suggestion would be usefull for me.Regard,Mike |
 |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-09-28 : 14:43:11
|
i'm still not sold on your approach, but without knowing more info it's hard to make a good judgement.So, I'll just give you the answer: The Application object in the Access object model has a method called "Eval()" -- read about it in Access VBA help.- Jeff |
 |
|
Hyukevain
Yak Posting Veteran
66 Posts |
Posted - 2004-09-28 : 21:01:35
|
For us, this is the simplest way to customize application in a short time. Maybe this is not the best way, but we can guarantee that this the fastest way to solve our problem.And, the "Eval()" method you just gave me work really good in solving our problem.... Thank's Jeff !!!!!Regard,Mike |
 |
|
|
|
|
|
|