By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,982 Members | 1,939 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,982 IT Pros & Developers. It's quick & easy.

Using Text Box Name as string?

P: n/a
I am creating a schedule using unbound text boxes. I have 280 text
boxes and I want to use the following code:

<<<CODE>>>

Private Sub Text8_Click()
If IsNull(Text8) Then
Text8 = " X "
Else
Text8 = Null
End If
End Sub

<<</CODE>>>

I am not looking forward to changing the text 279 times. Is there
another way to use a variable instead of typing each name in?

I tried Me.ActiveControl.Name, but it comes up with a type match error

Thanks for any help

Dave

Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
DaveA wrote:
I am creating a schedule using unbound text boxes. I have 280 text
boxes and I want to use the following code:

<<<CODE>>>

Private Sub Text8_Click()
If IsNull(Text8) Then
Text8 = " X "
Else
Text8 = Null
End If
End Sub

<<</CODE>>>

I am not looking forward to changing the text 279 times. Is there
another way to use a variable instead of typing each name in?

I tried Me.ActiveControl.Name, but it comes up with a type match error

Thanks for any help

Dave

Well, something like
If IsNull(Me(Me.ActiveControl.Name)) Then

You could create a function. Lets call it Junk
Private Function Junk()
If IsNull(Me(Me.ActiveControl.Name)) Then
Me(Me.ActiveControl.Name) = " x "
Else
Me(Me.ActiveControl.Name) = Null
End If
End Function

Now select all text boxes where you want this function to be called.
Open up the property sheet, select Event, and in the OnClick enter
=Junk()

Now all of your text boxes that were selected will execute that function.
Nov 13 '05 #2

P: n/a
That was just the thing! Works perfectly! My fingers thank you.
Dave

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.