Solved: Using variables in Forms!frmName.controlname etc
I use this vba in a form to set a textbox background on another open form like this;
This works fine of course.
Now the challenge is to use variables for the subform and control names.
This last line throws a 2465 error - app or object defind error
Any ideas please?
I use this vba in a form to set a textbox background on another open form like this;
Code:
Forms!frmsummary.[time line wills].Controls![txtdGuard].BackColor = vbYellow
This works fine of course.
Now the challenge is to use variables for the subform and control names.
Code:
dim subformname as string
dim controlname as string
subformname = "time line wills"
controlname = "txtdGuard"
Forms!frmsummary.(subformname).Controls!(controlname).BackColor = vbYellow
Any ideas please?
Last edited: