Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

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 ASP Free Forums Sponsor:
  #1  
Old October 21st, 2003, 06:23 PM
thejoemeister thejoemeister is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 6 thejoemeister User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question create a loop and assign a value for each field

I'm coding a form for MS ACCESS. When I lock/unlock fields, I do so declaring each field. How can I create a SUB that will loop through all the fields and assign the true/false value as needed. So that if I have 20 fields, I don't have to make 20 declarations?

Code is below, Thanks!!

JOE

Sub LockFields()
txtPhone.Locked = True
txtFirst.Locked = True
txtSS.Locked = True

End Sub

Sub UnlockFields()
txtPhone.Locked = False
txtFirst.Locked = False
txtSS.Locked = False


End Sub

--end of code--

Reply With Quote
  #2  
Old October 25th, 2003, 06:33 PM
m_lazor m_lazor is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Luxembourg
Posts: 156 m_lazor User rank is Corporal (100 - 500 Reputation Level)m_lazor User rank is Corporal (100 - 500 Reputation Level)m_lazor User rank is Corporal (100 - 500 Reputation Level)m_lazor User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Difficult to say what your intentions are. If you want to loop thru fields you should give them the same name "txtPhone" for ex. This creates an array of input elements and you either make a For Each..Next or For I = 0 to XXX..Next in order to acces each of them succesively.

Reply With Quote
  #3  
Old November 18th, 2003, 02:41 PM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 12
Don't know if you are still looking, but I found this in another forumn

Dim ctrl As Control

For Each ctrl In Me.Controls
If TypeOf ctrl Is TextBox Then ctrl.locked = True
' If TypeOf ctrl Is Label Then ctrl.Caption = ""
Next ctrl

S-

Reply With Quote
  #4  
Old November 18th, 2003, 04:26 PM
Stev Stev is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Queensland, Australia
Posts: 256 Stev User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 53 sec
Reputation Power: 5
I haven't done this for quite a while but you should be able to do this through the fields collection. The table object will have a fields collection which you can access in a similar way to an array using an index. I will look into it a bit further but in the meantime, which version are you using?

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft Access Help > create a loop and assign a value for each field


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway