473,385 Members | 1,337 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,385 software developers and data experts.

How to refer to a form control programmatically

If I have several text boxes on a form, ie. txtBox1, txtBox2, txtBox3,
etc., how can I refer to each in a loop. I want to do something
similar to this:

Dim i as Integer

for i = 0 to 2
(txtBox & cstr(i)) = something
next

The above does not work. Can I accomplish this via other means?
Thanks.

May 14 '06 #1
3 2324
On 14 May 2006 15:27:48 -0700, Vincent wrote:
If I have several text boxes on a form, ie. txtBox1, txtBox2, txtBox3,
etc., how can I refer to each in a loop. I want to do something
similar to this:

Dim i as Integer

for i = 0 to 2
(txtBox & cstr(i)) = something
next

The above does not work. Can I accomplish this via other means?
Thanks.


For i = 0 to 2
Me("txtBox" & i) = Something
Next i
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
May 14 '06 #2
Vincent wrote:
If I have several text boxes on a form, ie. txtBox1, txtBox2, txtBox3,
etc., how can I refer to each in a loop. I want to do something
similar to this:

Dim i as Integer

for i = 0 to 2
(txtBox & cstr(i)) = something
next

The above does not work. Can I accomplish this via other means?
Thanks.


Dim i as Integer

for i = 0 to 2
Me.Controls(txtBox & cstr(i)) = something
next

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
May 14 '06 #3
Rick Brandt wrote:
Vincent wrote:
If I have several text boxes on a form, ie. txtBox1, txtBox2,
txtBox3, etc., how can I refer to each in a loop. I want to do
something similar to this:

Dim i as Integer

for i = 0 to 2
(txtBox & cstr(i)) = something
next

The above does not work. Can I accomplish this via other means?
Thanks.


Dim i as Integer

for i = 0 to 2
Me.Controls(txtBox & cstr(i)) = something
next


As Fred's post indicates the txtBox above needs to be quoted.

for i = 0 to 2
Me.Controls("txtBox" & cstr(i)) = something
next
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


May 14 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: octagon | last post by:
Hi, I have a form with various types of control such as txtbox, combo box, listbox, subform and check box I am trying hard to write a code for a check box after check the box all the control in...
25
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
3
by: Joshua Ammann | last post by:
Hi, (Using Access 2000) I have two tables, similar to Customers and Orders. (Not an exact parallel, but works for this example.) On a form showing customer data, there is a tab control. One...
0
by: 23s | last post by:
Is there any way I can send a vertical value to a form's scroll position? I have a full-screen form that, at launch, contains an empty tab sheet. At run time, the user can dynamically append a...
9
by: mohit.akl | last post by:
Hey guys & gals I am havng trouble modifying the control box. I want to make the maximise button invisible and have minimisise button instead of it. Like this _ X (not like _ o X ) How...
1
by: inpuarg | last post by:
I have a windows form, there are button , textbox label etc. controls on it. and i can programmatically get each of their names. and i also have a printPreviewDialog on a form. I cannot get it...
5
by: masterej | last post by:
Developers, Is there any way to disable all checkboxes on a form? I have a form with 160 checkboxes and I want to be able to disable all of them. Is there a way I can do something like this: ...
4
by: Lysander | last post by:
I need a way of finding the name of the active control on a form. You can use currentdb() to refer to the current database You can use Me to refer to the active form or report. I need a...
12
EntryTeam
by: EntryTeam | last post by:
Hello every1. I'm trying to get OpenGL functions working inside windows forms, using #develop (SharpDevelop), which is great. I have this tutorial (in russian) and two files attached to it:...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

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.