Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / July 2007

Tip: Looking for answers? Try searching our database.

Basic code condense question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
TKM - 12 Jul 2007 16:58 GMT
Is thier a better way to condense this code then to have read the same way
over and over each time? I have 5 sets of these and each field is set to be
visible if the option box has a check mark in it. I am only showing you one
full set for the "IsDisplayHistoricalGrowth" option box. If sthere is an
eaier way to do this could someone let me know. I am pretty new at this.

Below is fired via the optionbox IsDisplayHistoricalGrowth
   Me.[YearFromHistoricalGrowth].Visible =
Nz(Me.[IsDisplayHistoricalGrowth], True)
       Me.[YearToHistoricalGrowth].Visible =
Nz(Me.[IsDisplayHistoricalGrowth], True)
           Me.[OneMileHistoricalGrowth].Visible =
Nz(Me.[IsDisplayHistoricalGrowth], True)
                Me.[ThreeMileHistoricalGrowth].Visible =
Nz(Me.[IsDisplayHistoricalGrowth], True)
                   Me.[FiveMileHistoricalGrowth].Visible =
Nz(Me.[IsDisplayHistoricalGrowth], True)
BeWyched - 12 Jul 2007 17:58 GMT
Try:

Dim flg as Boolean
flg = Nz(Me.[IsDisplayHistoricalGrowth], True)
With Me
   .[YearFromHistoricalGrowth].Visible =  flg
        .[YearToHistoricalGrowth].Visible = flg
            .[OneMileHistoricalGrowth].Visible = flg
                 .[ThreeMileHistoricalGrowth].Visible = flg
                    .[FiveMileHistoricalGrowth].Visible = flg
End With

> Is thier a better way to condense this code then to have read the same way
> over and over each time? I have 5 sets of these and each field is set to be
[quoted text clipped - 13 lines]
>                     Me.[FiveMileHistoricalGrowth].Visible =
> Nz(Me.[IsDisplayHistoricalGrowth], True)
Alex Dybenko - 12 Jul 2007 18:02 GMT
Hi,
you can, for example set a Tag property for each set of textboxes, and loop
through all controls of a form, and depending on selected checkmark and tag
of each textbox - set Visible property
you can also try to use control's name, if they are similar like
"*HistoricalGrowth"

Signature

Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

> Is thier a better way to condense this code then to have read the same way
> over and over each time? I have 5 sets of these and each field is set to
[quoted text clipped - 15 lines]
>                    Me.[FiveMileHistoricalGrowth].Visible =
> Nz(Me.[IsDisplayHistoricalGrowth], True)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.