Getting 'Call xxxx" routine from table

  • Thread starter Thread starter Douglas Sanders
  • Start date Start date
D

Douglas Sanders

Hi;

I have a timer event that checks for several things that might have to be
done.

I want to pull the name of the subroutine to call from a table containing
the necessary data something like this that doesn't work-

'Task to run
varX = DLookup("[Event_Routine]", "t_Events_List")
'Call the sub listed in the table
Call Str(varX)

This is preferred, but calling a macro would also make me happy.

Thanks,
Doug
 
Douglas Sanders said:
Hi;

I have a timer event that checks for several things that might have
to be done.

I want to pull the name of the subroutine to call from a table
containing the necessary data something like this that doesn't work-

'Task to run
varX = DLookup("[Event_Routine]", "t_Events_List")
'Call the sub listed in the table
Call Str(varX)

This is preferred, but calling a macro would also make me happy.

Thanks,
Doug

See if this works:

Dim varProcName As Variant

varProcName = DLookup("[Event_Routine]", "t_Events_List")

If Not IsNull(varProcName) Then
Application.Run varProcName
End If
 
Interesting:

It works fine with the call going to a module. I can live with that.
Can it call a sub in a form?

Thanks for your help.

Doug


Dirk Goldgar said:
Douglas Sanders said:
Hi;

I have a timer event that checks for several things that might have
to be done.

I want to pull the name of the subroutine to call from a table
containing the necessary data something like this that doesn't work-

'Task to run
varX = DLookup("[Event_Routine]", "t_Events_List")
'Call the sub listed in the table
Call Str(varX)

This is preferred, but calling a macro would also make me happy.

Thanks,
Doug

See if this works:

Dim varProcName As Variant

varProcName = DLookup("[Event_Routine]", "t_Events_List")

If Not IsNull(varProcName) Then
Application.Run varProcName
End If


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Douglas Sanders said:
Interesting:

It works fine with the call going to a module. I can live with that.
Can it call a sub in a form?

Not with Application.Run, as far as I know. If you want to call a
Function instead of a Sub, and you make it a Public Function, then you
can use Eval() to call the function so long as the form is open and you
qualify the function name with a reference to the form; e.g.,

Eval "Forms!YourFormName.YourFunctionName()"

However, I find that, although the function seems to be called okay,
error 2431 is raised afterward. I don't see why at the moment. It
isn't raised when I use the same syntax to call a function in a standard
module.
 
Doug


Dirk Goldgar said:
Not with Application.Run, as far as I know. If you want to call a
Function instead of a Sub, and you make it a Public Function, then you
can use Eval() to call the function so long as the form is open and you
qualify the function name with a reference to the form; e.g.,

Eval "Forms!YourFormName.YourFunctionName()"

However, I find that, although the function seems to be called okay,
error 2431 is raised afterward. I don't see why at the moment. It
isn't raised when I use the same syntax to call a function in a standard
module.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Back
Top