Dave B
Dave B

Reputation: 659

Programmatically Press Button

I am trying to dynamically press a command button.

I want to automate a number of tasks.

I have a task table. Each task has a FormName, CommandName field.

The form name and command name as list boxes that are automatically populated from the database objects.

When I press the execute button I want the following code to execute.

DoCmd.OpenForm Me.lstFormNames, , , , , acHidden

forms![lstformname].lstcommandname_Click()

However I cannot get it to execute properly. Any ideas?enter image description here

Upvotes: 1

Views: 2108

Answers (1)

MoondogsMaDawg
MoondogsMaDawg

Reputation: 1714

I found this question that covers CallByName. If this doesn't suit you, you can always copy the OnClick() code and paste into the routine you're trying to call the sub from. Here is the MSDN article on the function.

Upvotes: 2

Related Questions