Refer to Controls Using Variables (1 Viewer)

brucesilvers

Registered User.
Local time
Today, 09:23
Joined
Aug 4, 2000
Messages
70
I have a form with 25 related sets of text-box controls:

Product1, ProdDescr1, ProdQty1
Product2, ProdDescr2, ProdQty2
... Product25, ProdDescr25, ProdQty25

I need to loop through all 25 to check that the ProdQty for each is correct, and if any of them are incorrect, I'd like to set the BackColor to Red and the ForeColor to White for that particular set of controls. Rather than coding all 25 checks, I'd like to use variables to loop through the 25 sets

I understand how to create an incrementing Integer variable, but what is the correct syntax for combining that Integer variable with the String variables in order to perform the Back/Fore color commands?
 

pottera

Registered User.
Local time
Tomorrow, 02:23
Joined
Sep 3, 2002
Messages
236
Try this:
Code:
Dim iloop as integer
For iloop = 1 to 25
   Me("Product" & iloop).ForeColor = 16777215    ' or whatever white is
   Me("Product" & iloop).BackColor = 255
   Me("ProdDescr" & iloop).ForeColor = 16777215
   .
   .
Next iloop
 

brucesilvers

Registered User.
Local time
Today, 09:23
Joined
Aug 4, 2000
Messages
70
Thanks!!!

That syntax was exactly what I needed and my form is doing precisely what I'd hoped for. Thanks again :)
 

Users who are viewing this thread

Top Bottom