code from tables

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I have 2 public procedures, one called GradeAustralia, and the other called
GradeUK.

In a table called DBinfo which has two fields, one [description], the other
[value]. There is a record with the description Country and value is either
UK or Australia which is manualy typed in my the user depending on where they
are.

What I want is some code to run the procedure depending on what the country
is, so something like:

Run procedure with name = "Grade" &
Dlookup("Value","DBinfo","description='country'")

But it returns the value in the table in quotation marks. And I don't know
how to call it anyway.

I could use Select Case but I want to be able to add countries and
procedures without having to retype all the Select Case throughout the
database. Therefore I could just add a procedure called GradeUSA for example.
Then when the database is in USA they just type USA in the country box.

Hope you can help.

Many thanks

James
 
Ok As luck has it I just found the way,

Need to make a function in a module and put the name in a String eg:

Create function in a module called GradeAustralia or GradeUK

Then create this code where you want to call the function from:

Dim StrFunctionName as String

StrFunctionName = "Grade" & Dlookup("Value","DBinfo","Description='country'")
Run StrFunctionName


And that works

Thanks
James
 
If you want to return a value from the function, use the
Eval function:

ret = Eval(StrFunctionName & "()")
--
Marsh
MVP [MS Access]

Ok As luck has it I just found the way,

Need to make a function in a module and put the name in a String eg:

Create function in a module called GradeAustralia or GradeUK

Then create this code where you want to call the function from:

Dim StrFunctionName as String

StrFunctionName = "Grade" & Dlookup("Value","DBinfo","Description='country'")
Run StrFunctionName


James said:
I have 2 public procedures, one called GradeAustralia, and the other called
GradeUK.

In a table called DBinfo which has two fields, one [description], the other
[value]. There is a record with the description Country and value is either
UK or Australia which is manualy typed in my the user depending on where they
are.

What I want is some code to run the procedure depending on what the country
is, so something like:

Run procedure with name = "Grade" &
Dlookup("Value","DBinfo","description='country'")

But it returns the value in the table in quotation marks. And I don't know
how to call it anyway.

I could use Select Case but I want to be able to add countries and
procedures without having to retype all the Select Case throughout the
database. Therefore I could just add a procedure called GradeUSA for example.
Then when the database is in USA they just type USA in the country box.
 
Back
Top