Tex box Array

J

jeanhurtado

Hi!, I'm Jean and want to fill a text box "Location1.txt" with a part
number then go to another text box "Location2.txt" in a array. Here is
the code:

+++++++++++++++++++++++++++++++++++++++++++++++++
For z = 1 To 15

vlocbox = "location" + Trim(Str(z)) +
".Text"
vlocbox = aIAMSLoc(z)
' Clear the values of the arrays before the new PART
aIAMSLoc(z) = ""

Next z


I have 15 textboxes from location1 to location15. I have try but not
find and asnwer. How I can go from location1.txt to location2 , then
location3 in a array? Thanks for your help. Hope you can understand.

-Jean
 
S

storrboy

Hi!, I'm Jean and want to fill a text box "Location1.txt" with a part
number then go to another text box "Location2.txt" in a array. Here is
the code:

+++++++++++++++++++++++++++++++++++++++++++++++++
For z = 1 To 15

vlocbox = "location" + Trim(Str(z)) +
".Text"
vlocbox = aIAMSLoc(z)
' Clear the values of the arrays before the new PART
aIAMSLoc(z) = ""

Next z

I have 15 textboxes from location1 to location15. I have try but not
find and asnwer. How I can go from location1.txt to location2 , then
location3 in a array? Thanks for your help. Hope you can understand.

-Jean


Not sure what you are doing with the .txt after the Location, but
Access does not support control arrays. You're close in your use of
the For..Next loop, but it would be easier to iterate through the
different textboxes like this.

For z = 1 To 15
vlocbox ="location" & z
'Reference the control like this
Forms("frmName").Controls(vlocbox)
'or
Me.Controls(vlocbox)
Next z
 
J

jeanhurtado

Not sure what you are doing with the .txt after the Location, but
Access does not support control arrays. You're close in your use of
the For..Next loop, but it would be easier to iterate through the
different textboxes like this.

For z = 1 To 15
vlocbox ="location" & z
'Reference the control like this
Forms("frmName").Controls(vlocbox)
'or
Me.Controls(vlocbox)
Next z- Hide quoted text -

- Show quoted text -

I have try your method and seems to be good and looks like what I want
but an error comes when I implemented. It says: Compile error:
Invalid use of property
 
S

storrboy

I have try your method and seems to be good and looks like what I want
but an error comes when I implemented. It says: Compile error:
Invalid use of property


Post the entire function if you could. As I said you had things in
there I just didn't understand, you probably left some of that in
there.
 
J

jeanhurtado

I have try your method and seems to be good and looks like what I want
but an error comes when I implemented. It says: Compile error:
Invalid use of property- Hide quoted text -

- Show quoted text -

Let me explain better. I have the following code:

*****************************************************************
For z = 1 To 15
vlocbox = "location" + Trim(Str(z))

vlocbox.value = aIAMSLoc(z)

' Clear the values of the arrays before the new PART
aIAMSLoc(z) = ""

Next z
*****************************************************************

I want to fill "location1.txt" with the "aIAMSLoc(z)" value then when
it go to the next "Z" fill the next "aIAMSLoc(z)" value in the
"location2.txt" and then "Z" the fill the "aIAMSLoc(z)" value in the
"location3.txt" and go on. I have from location1.txt to
location15.txt. That's 15 textboxes.
 
S

storrboy

You forgot to include some of what I posted. You have to remember that
variables don't have properties, object do. vlocbox is a variable
representing the name of an object. You need to include the reference
to the object. I hope somewhere else in the function vlocbox is Dim'd
as a String and aIAMSLoc is Dim'd as an numeric array. Read the
comments inside the code snippet. Since you didn't provide the entire
proceedure, I can't get more concise or efficient than that.


For z = 1 To 15
' use + for math & for combining strings.
' Trim() and Str() are not required
vlocbox = "location" & z

'Replace frmName with the actual name of
'the form the text box is on
Forms("frmName").Controls(vlocbox)= _
aIAMSLoc(z)

' Clear the values of the arrays before the new
PART
aIAMSLoc(z) = ""

Next z
 
A

Albert D. Kallal

dim strlocBox as string

For z = 1 To 15
strlocbox = "location" & z
me(strlocbox) = aIAMSLoc(z)
' Clear the values of the arrays before the new PART
aIAMSLoc(z) = ""
Next z


A few things:

Do not use .text property in ms-access. We don't use it.
We use the .value property (or leave it out...which defaults to .value
as I show above). We could have
used:

me(strLocbox).Value = aIAMSLoc(z)


The ".text" property is ONLY valid in access when the control has the
focus, and further the value of the
control has not been yet updated (which means .text has not yet been
commited to the contorls ".value"
About the only use of .text is thus the "on-change" event (and character
by character processing). You
DO NOT NEED to use the .text propeirty. It is not valid 99% of the
time....

2nd:
use the & for concatenation, since the "+ is also doing double duty as
an addition operator, it not only
brings in confusing as to if you are adding a number, but you have to be
EXTRA CAUTIOUS that your
two strings are in fact strings. If one of the strings resolves to a
number, then ms-access actually will try
to add the numbers and NOT concatenate. To avoid this confusing when you
look at code, and also
access becoming confused....used the &
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top