Solved

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

Posted on 2012-12-27
2
257 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 49

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Attachment field in SQL 3 28
Access on Mouse move 5 35
Access check if a table is open 4 43
Access 2010 Compatibility With  Access 2010 Runtime 21 30
In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

809 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