dbTalk Databases Forums  

Looping through a Array of Controls labeled A1....A7 down to L1....L7

comp.databases.ms-access comp.databases.ms-access


Discuss Looping through a Array of Controls labeled A1....A7 down to L1....L7 in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Hardeep Rakhra
 
Posts: n/a

Default Looping through a Array of Controls labeled A1....A7 down to L1....L7 - 08-05-2003 , 05:02 PM






Heya,

Thanks for the help the other day it was most useful. Wonder if any one
would be able to help with this one.

I have an array of controls (those pesky text boxes from my last question),
labelled A1-A7 down to L1-L7

Basically I want to write a snippet of code that'll works it's way through
the array resetting each text box to a desired value.

I've had a look about the web and thanks to the faq posted on this group I
found some code that did what I wanted but only for one line of the array.
It works because each line contains incrementally numbered controls. The
problem is how do I get the A,B,C.....L bit to increment with each loop.

I want to do a loop with J = A to L and trap the 1 to 7 loop within, but how
do you increment a character. Does access even have a character type?

Hardeep.

----

Dim j As ????? <<< Dunno???
For j = A To L
Dim i As Integer
For i = 1 To 7
Me("j" & CStr(i)).Value = " ? "
Next
Next



Reply With Quote
  #2  
Old   
NoNotMe
 
Posts: n/a

Default Re: Looping through a Array of Controls labeled A1....A7 down to L1....L7 - 08-05-2003 , 05:14 PM






"Hardeep Rakhra" <news (AT) rakhra (DOT) org.uk> wrote

Quote:
Heya,

Thanks for the help the other day it was most useful. Wonder if any one
would be able to help with this one.

I have an array of controls (those pesky text boxes from my last
question),
labelled A1-A7 down to L1-L7

Basically I want to write a snippet of code that'll works it's way through
the array resetting each text box to a desired value.

I've had a look about the web and thanks to the faq posted on this group I
found some code that did what I wanted but only for one line of the array.
It works because each line contains incrementally numbered controls. The
problem is how do I get the A,B,C.....L bit to increment with each loop.

I want to do a loop with J = A to L and trap the 1 to 7 loop within, but
how
do you increment a character. Does access even have a character type?

Hardeep.

----

Dim j As ????? <<< Dunno???
For j = A To L
Dim i As Integer
For i = 1 To 7
Me("j" & CStr(i)).Value = " ? "
Next
Next
Like everything else there are multiple approaches...

For N = 65 To 76
L = Chr$(N)
' other stuff here
Me(L & I).Value=?
Next I




Reply With Quote
  #3  
Old   
Bob Quintal
 
Posts: n/a

Default Re: Looping through a Array of Controls labeled A1....A7 down to L1....L7 - 08-05-2003 , 05:17 PM



"Hardeep Rakhra" <news (AT) rakhra (DOT) org.uk> wrote in
news:bgp9gc$q182f$1 (AT) ID-152323 (DOT) news.uni-berlin.de:

Quote:
Heya,

Thanks for the help the other day it was most useful. Wonder if
any one would be able to help with this one.

I have an array of controls (those pesky text boxes from my last
question), labelled A1-A7 down to L1-L7

Basically I want to write a snippet of code that'll works it's way
through the array resetting each text box to a desired value.

I've had a look about the web and thanks to the faq posted on this
group I found some code that did what I wanted but only for one
line of the array. It works because each line contains
incrementally numbered controls. The problem is how do I get the
A,B,C.....L bit to increment with each loop.

I want to do a loop with J = A to L and trap the 1 to 7 loop
within, but how do you increment a character. Does access even
have a character type?

Hardeep.

----

Dim j As ????? <<< Dunno???
For j = A To L
Dim i As Integer
For i = 1 To 7
Me("j" & CStr(i)).Value = " ? "
Next
Next

Every character has an ASCII value. There are two useful functions,
ASC() which converts the letter to number and Chr(), which takes a
number and outputs a character.


so Dim i as integer, j as integer
for j = ASC("A") to ASC("J")
for i = 1 to 7
me(chr(j) & Cstr(i).value = " ? "
next
next

For a speed improvement use: for j = 65 to 74



Quote:
Bob




Reply With Quote
  #4  
Old   
Fletcher Arnold
 
Posts: n/a

Default Re: Looping through a Array of Controls labeled A1....A7 down to L1....L7 - 08-05-2003 , 05:34 PM




"Hardeep Rakhra" <news (AT) rakhra (DOT) org.uk> wrote

Quote:
Heya,

Thanks for the help the other day it was most useful. Wonder if any one
would be able to help with this one.

I have an array of controls (those pesky text boxes from my last
question),
labelled A1-A7 down to L1-L7

Basically I want to write a snippet of code that'll works it's way through
the array resetting each text box to a desired value.

I've had a look about the web and thanks to the faq posted on this group I
found some code that did what I wanted but only for one line of the array.
It works because each line contains incrementally numbered controls. The
problem is how do I get the A,B,C.....L bit to increment with each loop.

I want to do a loop with J = A to L and trap the 1 to 7 loop within, but
how
do you increment a character. Does access even have a character type?

Hardeep.

----

Dim j As ????? <<< Dunno???
For j = A To L
Dim i As Integer
For i = 1 To 7
Me("j" & CStr(i)).Value = " ? "
Next
Next

Assuming that when you say "labelled A1-A7 down to L1-L7", you actually mean
"named A1-A7 down to L1-L7", then you can try the following:

' ********************
Dim lngX As Long
Dim lngY As Long
Dim strN As String

For lngY = 65 To 76
For lngX = 1 To 7
strN = Chr$(lngY) & lngX
Me(strN) = "Whatever"
Next lngX
Next lngY

' ********************


HTH

Fletcher




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.