Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 20th, 2002, 07:38 AM
ECSUK ECSUK is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: North Yorkshire (U.K.)
Posts: 64 ECSUK User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #2  
Old June 7th, 2002, 03:20 PM
Waltjp's Avatar
Waltjp Waltjp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: NJ, USA
Posts: 91 Waltjp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #3  
Old June 7th, 2002, 05:12 PM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Central Florida, USA
Posts: 2,306 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 6 h 42 m 51 sec
Reputation Power: 60
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

Reply With Quote
  #4  
Old June 7th, 2002, 06:36 PM
Waltjp's Avatar
Waltjp Waltjp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: NJ, USA
Posts: 91 Waltjp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 1 m 8 sec
Reputation Power: 11
I agree on the '+', though JavaScript does allow it.

Reply With Quote
  #5  
Old June 9th, 2002, 05:18 AM
ECSUK ECSUK is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: North Yorkshire (U.K.)
Posts: 64 ECSUK User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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)

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Access97

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap