Solved

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

Posted on 2012-12-27
2
255 Views
Last Modified: 2012-12-27
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 ????
0
Comment
Question by:wlwebb
2 Comments
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 38723096
Hi,

False syntax n is a string you cannot add 1

Me(s & n) = Me(s & Format(CInt(n) + 1, "00"))

Regards
0
 

Author Closing Comment

by:wlwebb
ID: 38723255
OOps.... Thanks
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now