|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Access97
The procedure below is supposed to loop through the labels on a form intil it gets to a specific one (in this case a label named txt11000). I'm using Access97 but every time I try to run this, it gives a non specific error.
Also, the step value on the for statement gives an error, however, if I set it to -50, then it doesn't give an error!! ANY IDEAS??? Private Sub settextboxes( i As Integer) Dim j As Integer For j = 700 To 2000 step 50 Set Label = CommandBars.FindControl(msocontrolLabel, "txt" + i + j, , True) If j = 1000 Then 'Set backcolor of the label named txt11000 End If Next j End Sub |
|
#2
|
||||
|
||||
|
I suspect your problem is in the order of precedence. In the line starting "Set Label" you start by concatenating a string. The rest of the operation will read this as a string.
Thusly, you are not adding the values of i and j, but rather taking their string equivalents. If i = 100 j = 700 then "txt" + i + j will result in "txt100700" Try this For j = 700 To 2000 step 50 x = i + j Set Label = CommandBars.FindControl(msocontrolLabel, "txt" + x, , True) Walt Last edited by Waltjp : June 7th, 2002 at 03:23 PM. |
|
#3
|
|||
|
|||
|
Also, remember that "+" is not really a concatenation operator. Sometimes Access will through errors because you are adding mis-matched types. I believe the VBA concatenation operator is "&", so try changing the line in question to:
Code:
Set Label = CommandBars.FindControl(msocontrolLabel, "txt" & x, , True)
__________________
The real n-tier system: FreeBSD -> PostgreSQL -> [any_language] -> Apache -> Mozilla/XUL Amazon wishlist -- rycamor (at) gmail.com |
|
#4
|
||||
|
||||
|
I agree on the '+', though JavaScript does allow it.
|
|
#5
|
|||
|
|||
|
Thanks for the replies, I eventually got it to work using the following...
Me.Form.Controls("txt" + CStr(i) + CStr(mytimestr2)).BackColor = RGB(0, 0, 0) |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > Access97 |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|