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

Call Function based on data in a field

Status
Not open for further replies.

lancelotnz

Programmer
Mar 6, 2002
12
0
0
NZ
Hello All,

I have a recordset that populates command buttons on a form.

This recordset looks up a table that has the following fields: [SwitchboardID],[ItemNumber],[ItemText],[Command],[Argument] and [Status]

When the recordset is looping through populating the command buttons I want to run a function that decides whether or not to enable the command button.

The name of function I want to call is the text in the [Status] field.

I assumed it would be as simple as: Call rst![Status] or something similar.

Please help, would be appreciated.
 
If anyone is interested, I think I've got a work around for my problem.

I've built a function called Status(strStatus as String) with lots and lots of outcomes in a select case.

I can use the data in the [Status] Field in the recordset if I go: Status(rst![Status])

But I'm sure there's still a better way to do it...

 
How are ya lancelotnz . . . . .

How about this:
Code:
[blue]   Variable = [purple][b]Eval[/b][/purple](rst![Status] & "()")[/blue]

Calvin.gif
See Ya! . . . . . .
 
I'm good thank you AceMan, how 'bout yourself?

Thanks for your code but it doesn't seem to work for me. I get the following error: 'The expression you entered has a function name that <Name of Database> can’t find.'

And there is definately a function with that name.

Cheers for your time anyway.
 
lancelotnz . . . . .

Really! . . . . [blue]Status[/blue] should be name only no parenthese.

Try:
Code:
[blue]   Dim Funct As String

   Funct = rst![Status] & "()"
   Variable = Eval(Funct)[/blue]


Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top