Dynamic textbox question

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

Guest

Is there a way to set a textbox equal to a variable? For instance, can I do
something like this:

strTextbox = "txtName" 'the name of an actual textbox on a form.
set objTextbox = strTextbox

OR This:

set objTextbox = "txtName" & intCtr

where this would let me reference one of many similarly named text boxes
(i.e. txtName1, txtName2, etc). I've never been able to figure a way to do
this.

Thanks!
 
Is there a way to set a textbox equal to a variable? For instance, can I
do
something like this:

strTextbox = "txtName" 'the name of an actual textbox on a form.
set objTextbox = strTextbox

OR This:

set objTextbox = "txtName" & intCtr

This should work (untested):

Dim strTextBox As String
Dim objTextBox As Control

strTextBox = "txtName"

Set objTextBox = Me.Controls(strTextBox)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top