473,322 Members | 1,755 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,322 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 2217
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.