AllExperts > Experts 
Search      

Visual Basic

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More Visual Basic Answers
Question Library

Ask a question about Visual Basic
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Ravindra
Expertise
visual basic application programming from design to access information, sql, engineering and commercial applications. access databases, excel. Optional: 1)a large number of people want me to do work which takes some time and effort. Pl.note that i would like to be paid for such work. 2) if you want me to spend quality time and do special work, i expect to be paid a reasonable price for my time. 3) if you are pleased with my reply you could consider a donation of 1$. 4) you can visit my website http://ravindra.coolpage.biz (under constrn)

Experience

Past/Present clients
project work for a Norway company, and a Canadian company completed. Freelance Project work and Teaching
teaching vb

 
   

You are here:  Experts > Computing/Technology > Basic > Visual Basic > VBA 6.05 +Access 2003 EVAL function use

Topic: Visual Basic



Expert: Ravindra
Date: 8/25/2008
Subject: VBA 6.05 +Access 2003 EVAL function use

Question
Hi Ravindra:

Requested info: VBA verison 6.05, ADO version 2.8 +Access 2003 version 11, Intermediate knowledge with VB, but advanced in general programming.
Name: Annemarie Thomas

I am trying to modify the enabled & locked controls for a group of text boxes in a form in Access 2003.  They depend on a specific trimester.
For example, first trimester text boxes are labeled as shown in coding below.  
        With CurrentFormToSetup
                   .AllowEdits = True
                   .txtR_T1_Skill01.Enabled = True
                   .txtR_T1_Skill01.Locked = False
                   .txtR_T1_Skill02.Enabled = True
                   .txtR_T1_Skill02.Locked = False
                   .txtR_T1_Skill03.Enabled = True
                   .txtR_T1_Skill03.Locked = False
                   .txtR_T1_Skill04.Enabled = True
                   .txtR_T1_Skill04.Locked = False
                   (and so on)


Is there a way to use the EVAL function so that I can set say Current Trimester to 1, 2, or 3 depending on which set of controls I want to change and modify the code above so that I can use a FOR Loop 1 to 3 and thus don't have to list the code for 2nd and 3rd trimester separately as below, (only 2nd trimester shown here)
                   .txtR_T2_Skill01.Enabled = True
                   .txtR_T2_Skill01.Locked = False
                   .txtR_T2_Skill02.Enabled = True
                   .txtR_T2_Skill02.Locked = False
                   .txtR_T2_Skill03.Enabled = True
                   .txtR_T2_Skill03.Locked = False
                   .txtR_T2_Skill04.Enabled = True
                   .txtR_T2_Skill04.Locked = False
                   (and so on)

I tried for example EVAL(".txtR_T" & CurrrentTrimester & "_Skill01.Enabled = True"), but I get an error.

Some of my forms have more 10 or more text boxes for each trimester, so it would really shorten my coding if I could do that.

Thanks

Answer
you could use a function like Private  function Selector(olage as integer)

and in the function add
select case olage

case 1
'... code for Trmester 1

case 2
..code for Trmester 2

'and so on

end  select

call for this function based on your input or use a loop to pass thro all instances.

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.