473,408 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Execute a string as an object

mshmyob
904 Expert 512MB
I create a text string like so in a loop

vBox = "Me.txtLetter" & CStr(vCounter) & ".visible=true"

This will result in vBox = "Me.txtLetter1.visible=true"
The number 1 will cycle through all the way to 26 if need be

There are 26 boxes on my screen a and I want to turn them on or off.

I need to execute vBox.

I hope you understand what I am trying to say. Is there anyway to do it in Access. I know in the old DOS dbase days you could just say &vBox and it would convert what was in the vBox variable into a statement.
Jan 9 '08 #1
7 2221
Rabbit
12,516 Expert Mod 8TB
The usual way of doing this is:
Expand|Select|Wrap|Line Numbers
  1. Me.Controls("txtLetter" & vCounter).Visible = True
  2.  
Jan 9 '08 #2
mshmyob
904 Expert 512MB
Rabbit you are a GENIUS!!! Thanks it worked perfectly.

The usual way of doing this is:
Expand|Select|Wrap|Line Numbers
  1. Me.Controls("txtLetter" & vCounter).Visible = True
  2.  
Jan 9 '08 #3
Rabbit
12,516 Expert Mod 8TB
Not a problem.
Jan 9 '08 #4
mshmyob
904 Expert 512MB
Just out of curiosity is there a way to do what I asked in case I need to do it in the future.

Not a problem.
Jan 9 '08 #5
Rabbit
12,516 Expert Mod 8TB
Just out of curiosity is there a way to do what I asked in case I need to do it in the future.
Not that I know of, you can try the Evaluate() function but I don't think it evaluates vba.

But it doesn't matter, I can't think of a time when you'd have to do it that way.
Jan 9 '08 #6
ADezii
8,834 Expert 8TB
I create a text string like so in a loop

vBox = "Me.txtLetter" & CStr(vCounter) & ".visible=true"

This will result in vBox = "Me.txtLetter1.visible=true"
The number 1 will cycle through all the way to 26 if need be

There are 26 boxes on my screen a and I want to turn them on or off.

I need to execute vBox.

I hope you understand what I am trying to say. Is there anyway to do it in Access. I know in the old DOS dbase days you could just say &vBox and it would convert what was in the vBox variable into a statement.
To the best of my knowledge, there is no way that this can be accomplished in Access via the manner which you describe. The Eval() Function can not be used in this context, also. Rabbit described the only sensible Method of cycling through all 26 Text Boxes named txtLetter1 thru txtLetter26, if you so desired. To expand on Rabbit's Reply:
Expand|Select|Wrap|Line Numbers
  1. Const conNumOfControls As Integer = 26
  2. Dim intCounter As Integer
  3.  
  4. For intCounter = 1 To conNumOfControls
  5.   Me.Controls("txtLetter" & CStr(intCounter)).Visible = False
  6. Next
Jan 10 '08 #7
mshmyob
904 Expert 512MB
Thanks. I did get Rabbit's suggestion to work and it works beautifully. I was just wondering if it could be done the way I originally was thinking. It appears it cannot.

To the best of my knowledge, there is no way that this can be accomplished in Access via the manner which you describe. The Eval() Function can not be used in this context, also. Rabbit described the only sensible Method of cycling through all 26 Text Boxes named txtLetter1 thru txtLetter26, if you so desired. To expand on Rabbit's Reply:
Expand|Select|Wrap|Line Numbers
  1. Const conNumOfControls As Integer = 26
  2. Dim intCounter As Integer
  3.  
  4. For intCounter = 1 To conNumOfControls
  5.   Me.Controls("txtLetter" & CStr(intCounter)).Visible = False
  6. Next
Jan 10 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Matt | last post by:
I want to exexute stored procedure in ASP, but it has error "Microsoft VBScript compilation (0x800A0401) Expected end of statement" on line (1). The stored procedure "sp_emp" contain "select *...
2
by: michaaal | last post by:
I feel a bit silly asking this because I use this code all the time, but what does the ",,129" mean? Are there other parameters that one might use (I only do fairly simple SQL commands). ...
7
by: William Gill | last post by:
I have been trying to pass parameters as indicated in the api. when I use: sql= 'select * from %s where cusid = %s ' % name,recID) Cursor.execute(sql) it works fine, but when I try : sql=...
3
by: Lyle Fairfield | last post by:
MS-SQL Server utilities Enterprise Manager and Query Analyzer will model almost any MS-SQL object as a simple script file with a default ".sql" extension. But how to "run these files? They are...
8
by: Jiggaz | last post by:
Hi, In my ASPX Page, i have a form for signup. And whene user click on the button, the event Button1_Click must use a stored procedure. But instead of use stored proc, i get this exception :...
3
by: Peter Afonin | last post by:
Hello, Our SQL server used to run under System account, and I had no problems executing DTS packages from the ASP.NET: Dim oPkg As DTS.Package oPkg = CreateObject("DTS.Package")...
9
by: tshad | last post by:
I have an example I copied from "programming asp.net" (o'reilly) and can't seem to get the Sub (writefile) to execute. It displays all the response.write lines that are called directly, but not...
1
by: sjallard | last post by:
Hi, I'd like to do something like that (see explanations after the code snippet) : Sub mainSub (foo as String) Dim msScript As New ScriptControl msScript.Language = "VBScript" Dim someVar...
2
by: Sike | last post by:
Hi everyone, I've been browsing this and a few other related newsgroups trying to get my head around this problem, and so far all the trails seem to go cold, without an acceptable solution being...
5
by: Neil | last post by:
Hi, Long story short, we use "Server.Execute" to grab the output from an ASPX page ... Server.Execute("page.aspx", textWriter); We've noticed that intermittantly, we get a "Thread was being...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.