473,769 Members | 5,787 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Control array on form

Is it possible to create a control array on an unbound form? I would
like to be able to loop through a series of unbound text boxes.

Thanks.
Nov 13 '05 #1
2 18606
Sort of, but not exactly like in VB6 or VB8 (note: version VB7 doesn't
support control arrays) where you create one control and then copy the
same control multiple times. Control arrays are a form of inheritance
(but that is at the design level of VB which was developed in some
version of C). You can simulate control arrays in Access by creating a
textbox and then keep copying it (or just keep creating new textboxes)
and then naming the textboxes like txt0, txt1, txt2, ...

In a VB control array you can loop through the control like

For i = 0 to 5 : Debug.Print txtN(0).Text : Next

In Access you can do this:

Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then Debug.Print ctl.Name
Next

Of course, for this example, the textboxes could be named anything. But
here is a better simulation of control arrays in Access

Dim i As Integer
For i = 0 To 4
Debug.Print Me.Controls("tx t" & i).Name
Next

Or another option would be to stuff the textboxes into a Collection
object. Then you can loop through the collection object

Dim col As New Collection, v As Variant
For i = 0 To 4: col.Add Me.Controls("tx t" & i): Next
For Each v In col: Debug.Print v.Name: Next

Then only catch is that you have to know ahead of time how many
textboxes you have in Access where a VB control array knows
automatically. Of course, you could always just loop through the
controls collection of your form and anything that is a textbox gets
stuffed into the collection object (again, the textboxes could be named
anything in this case).

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #2
ra*****@hotmail .com (RBohannon) wrote in message news:<ad******* *************** ****@posting.go ogle.com>...
Is it possible to create a control array on an unbound form? I would
like to be able to loop through a series of unbound text boxes.

Thanks.


Nope. Access VBA <> normal VB, where you *can* have control arrays.
You have to name your controls similarly... ie

txtControl1, txtControl2, etc and then you can do something like this.

'warning - pathetic code ahead... but it *does* work

Private Sub Command6_Click( )
Dim strControlName As String
Dim intCounter As Integer
strControlName = "Text"
For intCounter = 0 To 4 Step 2
Me.Controls(str ControlName & intCounter).Val ue = intCounter
Next intCounter

End Sub

In my case I have Text0, Text2, Text4 as my textboxes...
Nov 13 '05 #3

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

Similar topics

9
2932
by: ckerns | last post by:
I want to loop thru an array of controls,(39 of them...defaults = 0). If value is null or non-numeric I want to assign the value of "0". rowString = "L411" //conrol name if (isNaN(eval ("document.forms."+rowString+".value")) == true ) { //this alert works if the value is a letter,i.e,"a" alert("You have entered an non-numeric value.\nEnter a number in the appropriate box.");
7
1521
by: Jacky Luk | last post by:
Does anyone know of a downloadable Line ActiveX control which allows me to plot straight lines on a VC++.NET form? Thanks Jack
0
1671
by: RSB | last post by:
Hi Every one, i am trying to create a UserControl and i am passing a Array of strings to it. Now based on the Array elements i am creating the LinkButtons Dynamically. I am also passing a Event to this control and Lining the OnClick event of these LinkButtons to this Event. (Which works fine). Now the Thing which i cannot achieve is i want to Change the Back Color of the Clicked to LinkButton To a different color and i also don't want to...
7
6398
by: Tom wilson | last post by:
I'm trying to create dynamic controls in ASP.Net. It's driving me nuts. I keep getting the error: Control '16' of type 'RadioButton' must be placed inside a form tag with runat=server. Dim Place1 As New PlaceHolder Controls.Add(Place1) For y = 1 To Choices.RecordCount Choices.MoveTo(y)
9
6101
by: Sarfaraz Khan | last post by:
Hello, anyone can guid me how we can handle and define control array in vb.net? Thanks & regards SARFARAZ KHAN
14
1582
by: Jim Burns | last post by:
I just started with vb.net and I don't understand why there are no control arrays. what replaced them. I was trying to do drag and drop(What happened with that) and it looked like with no control array I have to write code in for every control? That cant be possible. I looked at the help files and it looks like I can set an event handler but there has to be a better way then typing Handles pic1.click,pic2.click It would be a lot of...
4
1697
by: Rich | last post by:
Hello, I have 3 textboxes and 1 combobox on a form. On entering the control I want to select all the text. I can make an array of textboxes like this: Dim arrTxt As TextBox() = {txt1, txt2, txt3} Then I loop through that array Private Sub onEntering(ByVal sender As Object, ...) Handles _
6
3059
by: Rich | last post by:
Hello, I have an application that contains several checkboxes. I originally created this app in VB.Net 2003 and upgraded the app to VB.Net 2005. I understand the vb2005 supports control arrays. Is this correct? If so, I would like to convert my checkboxes to a control array, but without having to recreate them from scratch because their placement was a real pain. Is it possible to go to the property sheet of each checkbox and assign...
2
2650
by: deccio | last post by:
I have create an activex Control with Visual studio 2005 and framework 2.0 in c# to add drag & drop functionality to upload multi file. When I use it in a windows form it work fine. Infact if I select 3 files from a windows explorer and I move it in a listbox in my activeX, I find my 3 files added in the listbox but if I use my activeX in a web form and I select 3 file from a windows explorer in the listBox find only 1 file the file on...
0
9583
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10039
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7406
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6668
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5445
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3955
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3560
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.