The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Databases
> Database Management
|
Access97
Discuss Access97 in the Database Management forum on Dev Shed. Access97 Database Management forum discussing non-database specific SQL. Structured Query Language was designed to be a robust and standardized language for manipulating relational databases.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

May 20th, 2002, 07:38 AM
|
|
Contributing User
|
|
Join Date: Mar 2001
Location: North Yorkshire (U.K.)
Posts: 64
Time spent in forums: 5 h 24 m 18 sec
Reputation Power: 13
|
|
|
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
|

June 7th, 2002, 03:20 PM
|
 |
Contributing User
|
|
Join Date: May 2002
Location: NJ, USA
Posts: 91
Time spent in forums: 1 h 1 m 8 sec
Reputation Power: 11
|
|
|
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.
|

June 7th, 2002, 05:12 PM
|
|
Gödelian monster
|
|
Join Date: Jul 1999
Location: Central Florida, USA
|
|
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)
|

June 7th, 2002, 06:36 PM
|
 |
Contributing User
|
|
Join Date: May 2002
Location: NJ, USA
Posts: 91
Time spent in forums: 1 h 1 m 8 sec
Reputation Power: 11
|
|
|
I agree on the '+', though JavaScript does allow it.
|

June 9th, 2002, 05:18 AM
|
|
Contributing User
|
|
Join Date: Mar 2001
Location: North Yorkshire (U.K.)
Posts: 64
Time spent in forums: 5 h 24 m 18 sec
Reputation Power: 13
|
|
|
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)
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|