473,738 Members | 7,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question 1: How to refer to a arrayed multple textbox?


Hi,

I am having two problems with Access 97. These '2 problems are posted
seperately in this newsgroup. Here's the first:

I have a form with lots of similar textboxes and I have a procedure that

acts on all these textboxes. Therefore I would like to refer to these
textboxes as an array.

My real form is somewhat more complicated, so for simplicity: Let's say
I
have a form with 5 textboxes who's name is "JanTextBox (1)" until
"JanTextBox(5)" . I also have a button called "JanButton" and this button
has this code (on click):

Private Sub JanButton_Click ()

Dim X As Integer

For X = 1 To 5
JanTextBox(X).E nabled = True
Next

End Sub

This yields the error : "Compile Error function or subfunction not
defined"
So it sees JanTextBox as a function. So I tell him this is an object.

Private Sub JanButton_Click ()

Dim X As Integer
Dim JanTextBox(1 To 5) As TextBox

For X = 1 To 5
TextBox(Teller) .Enabled = True
Next

End Sub

This is also not accepted: "Run time error '91':
Object variable or With block variable not set."
So does it want a 'set' statement? Let's try:

Private Sub JanButton_Click ()

Dim X As Integer
Dim JanTextBox(1 To 5) As TextBox
Dim OtherBox As TextBox

For X = 1 To 5
Set OtherBox = JanTextBox(X)
OtherBox.Enable d = True
Next

End Sub

This gives the same result: "Run time error '91':
Object variable or With block variable not set."
It seems like Access doesn't want to recognize "JanTextBox (X)" as an
array
of textboxes.

How can I declare textboxes in an array like way?

Thanks: jan Veenstra
(For your information:

My initial solution however works but looks quite awkward
and I was trying to avoid this solution:
Renaming all JanTextBox(X) to JanTextBoxX:

Private Sub JanButton_Click ()

JanTextBox1.Ena bled = True
JanTextBox2.Ena bled = True
JanTextBox3.Ena bled = True
JanTextBox4.Ena bled = True
JanTextBox5.Ena bled = True

End Sub
)

--
..

Nov 13 '05 #1
8 1610
Try this:
Private Sub JanButton_Click ()
Dim X As Integer
For X = 1 To 5
Me("JanTextBox " & X)..Enabled = True
Next
End Sub

Arno R

"jan Veenstra" <ve*********@ho tmail.com> schreef in bericht news:42******** *******@hotmail .com...

Hi,

I am having two problems with Access 97. These '2 problems are posted
seperately in this newsgroup. Here's the first:

I have a form with lots of similar textboxes and I have a procedure that

acts on all these textboxes. Therefore I would like to refer to these
textboxes as an array.

My real form is somewhat more complicated, so for simplicity: Let's say
I
have a form with 5 textboxes who's name is "JanTextBox (1)" until
"JanTextBox(5)" . I also have a button called "JanButton" and this button
has this code (on click):

Private Sub JanButton_Click ()

Dim X As Integer

For X = 1 To 5
JanTextBox(X).E nabled = True
Next

End Sub

This yields the error : "Compile Error function or subfunction not
defined"
So it sees JanTextBox as a function. So I tell him this is an object.

Private Sub JanButton_Click ()

Dim X As Integer
Dim JanTextBox(1 To 5) As TextBox

For X = 1 To 5
TextBox(Teller) .Enabled = True
Next

End Sub

This is also not accepted: "Run time error '91':
Object variable or With block variable not set."
So does it want a 'set' statement? Let's try:

Private Sub JanButton_Click ()

Dim X As Integer
Dim JanTextBox(1 To 5) As TextBox
Dim OtherBox As TextBox

For X = 1 To 5
Set OtherBox = JanTextBox(X)
OtherBox.Enable d = True
Next

End Sub

This gives the same result: "Run time error '91':
Object variable or With block variable not set."
It seems like Access doesn't want to recognize "JanTextBox (X)" as an
array
of textboxes.

How can I declare textboxes in an array like way?

Thanks: jan Veenstra


(For your information:

My initial solution however works but looks quite awkward
and I was trying to avoid this solution:
Renaming all JanTextBox(X) to JanTextBoxX:

Private Sub JanButton_Click ()

JanTextBox1.Ena bled = True
JanTextBox2.Ena bled = True
JanTextBox3.Ena bled = True
JanTextBox4.Ena bled = True
JanTextBox5.Ena bled = True

End Sub
)

--
.

Nov 13 '05 #2
Try this

Private Sub Command15_Click ()
Dim cntl As Control
Dim iLoop As Byte
For Each cntl In Me.Controls
For iLoop = 1 To 5
If cntl.Name = "anTextBox" & CStr(iLoop) Then
Me(cntl.Name).E nabled = True
Next iLoop
Next cntl
End Sub
Filip
"jan Veenstra" <ve*********@ho tmail.com> wrote in message
news:42******** *******@hotmail .com...

Hi,

I am having two problems with Access 97. These '2 problems are posted
seperately in this newsgroup. Here's the first:

I have a form with lots of similar textboxes and I have a procedure that

acts on all these textboxes. Therefore I would like to refer to these
textboxes as an array.

My real form is somewhat more complicated, so for simplicity: Let's say
I
have a form with 5 textboxes who's name is "JanTextBox (1)" until
"JanTextBox(5)" . I also have a button called "JanButton" and this button
has this code (on click):

Private Sub JanButton_Click ()

Dim X As Integer

For X = 1 To 5
JanTextBox(X).E nabled = True
Next

End Sub

This yields the error : "Compile Error function or subfunction not
defined"
So it sees JanTextBox as a function. So I tell him this is an object.

Private Sub JanButton_Click ()

Dim X As Integer
Dim JanTextBox(1 To 5) As TextBox

For X = 1 To 5
TextBox(Teller) .Enabled = True
Next

End Sub

This is also not accepted: "Run time error '91':
Object variable or With block variable not set."
So does it want a 'set' statement? Let's try:

Private Sub JanButton_Click ()

Dim X As Integer
Dim JanTextBox(1 To 5) As TextBox
Dim OtherBox As TextBox

For X = 1 To 5
Set OtherBox = JanTextBox(X)
OtherBox.Enable d = True
Next

End Sub

This gives the same result: "Run time error '91':
Object variable or With block variable not set."
It seems like Access doesn't want to recognize "JanTextBox (X)" as an
array
of textboxes.

How can I declare textboxes in an array like way?

Thanks: jan Veenstra
(For your information:

My initial solution however works but looks quite awkward
and I was trying to avoid this solution:
Renaming all JanTextBox(X) to JanTextBoxX:

Private Sub JanButton_Click ()

JanTextBox1.Ena bled = True
JanTextBox2.Ena bled = True
JanTextBox3.Ena bled = True
JanTextBox4.Ena bled = True
JanTextBox5.Ena bled = True

End Sub
)

--
.

Nov 13 '05 #3
"Arno R" <ar***********@ tiscali.nl> wrote in
news:42******** *************@d reader2.news.ti scali.nl:
Private Sub JanButton_Click ()
Dim X As Integer
For X = 1 To 5
Me("JanTextBox " & X)..Enabled = True
Next
End Sub


While that works because of implicit type coercion, I think it's
always best to explicity coerce numeric types to strings when you
know that's what you have. So, I would have this, instead:

Dim X As Integer
For X = 1 To 5
Me("JanTextBox " & CStr(X()).Enabl ed = True
Next

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #4
Dim X As Integer
For X = 1 To 5
Me("JanTextBox " & CStr(X()).Enabl ed = True 'Errase the '(' after X
Next

"Filips Benoit" <be***********@ pandora.be> wrote in message
news:G2******** **************@ phobos.telenet-ops.be...
Try this

Private Sub Command15_Click ()
Dim cntl As Control
Dim iLoop As Byte
For Each cntl In Me.Controls
For iLoop = 1 To 5
If cntl.Name = "anTextBox" & CStr(iLoop) Then
Me(cntl.Name).E nabled = True
Next iLoop
Next cntl
End Sub
Filip
"jan Veenstra" <ve*********@ho tmail.com> wrote in message
news:42******** *******@hotmail .com...

Hi,

I am having two problems with Access 97. These '2 problems are posted
seperately in this newsgroup. Here's the first:

I have a form with lots of similar textboxes and I have a procedure that

acts on all these textboxes. Therefore I would like to refer to these
textboxes as an array.

My real form is somewhat more complicated, so for simplicity: Let's say
I
have a form with 5 textboxes who's name is "JanTextBox (1)" until
"JanTextBox(5)" . I also have a button called "JanButton" and this button
has this code (on click):

Private Sub JanButton_Click ()

Dim X As Integer

For X = 1 To 5
JanTextBox(X).E nabled = True
Next

End Sub

This yields the error : "Compile Error function or subfunction not
defined"
So it sees JanTextBox as a function. So I tell him this is an object.

Private Sub JanButton_Click ()

Dim X As Integer
Dim JanTextBox(1 To 5) As TextBox

For X = 1 To 5
TextBox(Teller) .Enabled = True
Next

End Sub

This is also not accepted: "Run time error '91':
Object variable or With block variable not set."
So does it want a 'set' statement? Let's try:

Private Sub JanButton_Click ()

Dim X As Integer
Dim JanTextBox(1 To 5) As TextBox
Dim OtherBox As TextBox

For X = 1 To 5
Set OtherBox = JanTextBox(X)
OtherBox.Enable d = True
Next

End Sub

This gives the same result: "Run time error '91':
Object variable or With block variable not set."
It seems like Access doesn't want to recognize "JanTextBox (X)" as an
array
of textboxes.

How can I declare textboxes in an array like way?

Thanks: jan Veenstra
(For your information:

My initial solution however works but looks quite awkward
and I was trying to avoid this solution:
Renaming all JanTextBox(X) to JanTextBoxX:

Private Sub JanButton_Click ()

JanTextBox1.Ena bled = True
JanTextBox2.Ena bled = True
JanTextBox3.Ena bled = True
JanTextBox4.Ena bled = True
JanTextBox5.Ena bled = True

End Sub
)

--
.


Nov 13 '05 #5

"David W. Fenton" <dX********@bwa y.net.invalid> schreef in bericht news:Xn******** *************** ***********@24. 168.128.86...
"Arno R" <ar***********@ tiscali.nl> wrote in
news:42******** *************@d reader2.news.ti scali.nl:
Private Sub JanButton_Click ()
Dim X As Integer
For X = 1 To 5
Me("JanTextBox " & X)..Enabled = True
Next
End Sub


While that works because of implicit type coercion, I think it's
always best to explicity coerce numeric types to strings when you
know that's what you have. So, I would have this, instead:

Dim X As Integer
For X = 1 To 5
Me("JanTextBox " & CStr(X()).Enabl ed = True
Next

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc


While my solution works and your solution won't ... ;-)
you are very right on the implicit vs. explicit issue.

You should have: Me("JanTextBox " & CStr(X)).Enable d = True

Arno R
Nov 13 '05 #6
"Arno R" <ar***********@ tiscali.nl> wrote in
news:42******** *************@d reader2.news.ti scali.nl:
"David W. Fenton" <dX********@bwa y.net.invalid> schreef in bericht
news:Xn******** *************** ***********@24. 168.128.86...
"Arno R" <ar***********@ tiscali.nl> wrote in
news:42******** *************@d reader2.news.ti scali.nl:
Private Sub JanButton_Click ()
Dim X As Integer
For X = 1 To 5
Me("JanTextBox " & X)..Enabled = True
Next
End Sub
While that works because of implicit type coercion, I think it's
always best to explicity coerce numeric types to strings when you
know that's what you have. So, I would have this, instead:

Dim X As Integer
For X = 1 To 5
Me("JanTextBox " & CStr(X()).Enabl ed = True
Next

--
David W. Fenton
http://www.bway.net/~dfenton dfenton at bway dot net
http://www.bway.net/~dfassoc


While my solution works and your solution won't ... ;-)
you are very right on the implicit vs. explicit issue.


Heh.
You should have: Me("JanTextBox " & CStr(X)).Enable d = True


That will teach me to post after coming back from the optometrist
after having my eyes dilated!

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #7
"Filips Benoit" <be***********@ pandora.be> wrote in
news:G2******** **************@ phobos.telenet-ops.be:
Private Sub Command15_Click ()
Dim cntl As Control
Dim iLoop As Byte
For Each cntl In Me.Controls
For iLoop = 1 To 5
If cntl.Name = "anTextBox" & CStr(iLoop) Then
Me(cntl.Name).E nabled = True
Next iLoop
Next cntl
End Sub


This is the kind of thing that seems to me to call out for a custom
collection.

You'd assign control references to the collection in the form's
OnLoad event, then when you want to enable controls, you'd just loop
through the collection.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #8
"David W. Fenton" wrote:
"Arno R" <ar***********@ tiscali.nl> wrote in
news:42******** *************@d reader2.news.ti scali.nl:


Thanks guys. This really helped!

--
..

Nov 13 '05 #9

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

Similar topics

3
4143
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 of the tabs has a subform showing order data (in datasheet view). On the same tab there is an unbound textbox (next to the datasheet). I placed a
1
1330
by: Paul | last post by:
I have a MDI container form "frmParent". On that form there is a tabstrip control with 2 pages. On one of those pages there is a textbox and a button. When the user clicks on the button a child form is opened inside the container form "frmChild" which displays a datagrid. The WHERE clause in the select statement which is bound to the grid comes from the textbox on the Parent form. How do I refer to this textbox control ?
1
1214
by: Agnes | last post by:
in my tables, there are 20 fields, 15fields are bind to the textbox. however, some fields won't shown in the textbox , but I need to update it also. For example, i will increment the version , userid, savedate behind the form (not shown in the textbox) How can I do that ? Thanks
6
2293
by: Ludwig | last post by:
Hi, i'm using the regular expression \b\w to find the beginning of a word, in my C# application. If the word is 'public', for example, it works. However, if the word is '<public', it does not work: it seems that < is not a valid character, so the beginning of the word starts at theletter 'p' instead of '<'. Because I'm not an expert in regular expressions, maybe someone of you guys can help me? I need the correct regex to find the...
3
1601
by: Miro | last post by:
First off...thanks in advance for getting me this far. Sorry for all these class posts but im having a heck of a time here trying to get something to work, and have finally got it to work ( yahooooo ) but i dont know why now I cant get it to work the other way. Vb 2003 Below are 2 examples. One Does not work and the other does.
1
1186
by: charmgirl | last post by:
hi, is it possible to have multple forms in a page. if yes than how to read data from multople forms ?
2
7666
by: Ken Fine | last post by:
I want to add the security question and answer security feature to the ChangePassword control. I am aware that this functionality is built into the PasswordRecovery tool. I have implemented the PasswordRecovery with a Password reset required; a temporary password is sent to the account on file. I want an extra layer of security to accommodate the very unlikely contingency that someone's e-mail account is compromised. Challenging with the...
4
1307
by: phub11 | last post by:
Hi all, I have two pre-defined arrays; array1 = car, 1, tony; array2 = bus, 3, mike; I would like to make these into an arrayed array such that arrayFinal=tony. I've looked at array_merge and array_combine, but they don't appear to do what I want. All the examples I can only find multidimensional array examples that use scripted input rather than using pre-existing arrays. Any ideas ?
5
1868
by: KingKen | last post by:
I have a situation whereby I have to enter many records in a db that only have one field that changes. For example software installed on a computer would give you many different rows of data with just a single variant in the software field. I want to know if it is possible to have my form setup in such a way that it takes one instance of constant data and various instances of a variant field but for each variant create a new record and add...
0
8969
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
9335
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
9263
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9208
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8210
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6053
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
4570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.