troubleshooting Question

Access - VB for correct Syntax to use concanation of two variables when refering to a Textbox Control

Avatar of wlwebb
wlwebbFlag for United States of America asked on
Microsoft Access
2 Comments1 Solution283 ViewsLast Modified:
Hello All

I don't know all the terms well enough to know if my Title of this thread was worded correctly but here goes.....

I have a code where I am attempting to use two variables to allow it to do a series of things automatically.  My Textbox names all end with ## where ## are sequential numbered 01, 02, 03, 04 etc.....

Let's assume for this example my textboxes are Named txtbox01, txtbox02,txtbox03 etc..

Now then, I know I can write the code with something like this:

Me("txtbox" & n) = me("txtbox" & n+1)

Now I got the crazy thought, "hey what if I have to change the name and figure out my code"..... So I thought if using the me("xxxx"&n) worked so well, why can't I use something like me(s & n) = me(s & n+1)........where s & n are String variables.

Private sub xxxx
Dim n as String, s as String

s = Left(Me.ActiveControl.Name, (Len(Me.ActiveControl.Name) - 2))
n= Right(Me.ActiveControl.Name, 2)

Me(s & n) = Me(s & n+1)
End sub

Then just copy that coding to the afterupdate event of all the textboxes I want to use that for......

However, it doesn't work.........  is there a way to alter it to fix that ????
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros