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 / Forms Programming / June 2007

Tip: Looking for answers? Try searching our database.

Assigning dynamic contol name properties

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mymind - 20 Jun 2007 19:55 GMT
I have a form that contains twenty controls for # of hours, Sum of hours, and
hours_label.  (example:  A1_Hours, A2_Hours....,A20_Hours  and   A1_HoursSum,
A2_HoursSum....,A20HoursSum and
A1_Hours_Label,A2_Hours_Label....A20_Hours_Label )

I have created a private sub that loops through a datasource that contains
up to 20 label captions.  Based upon the number of captions (x)  I would like
to set the associated control properies:

Example:
x=1
Do While Not rs.EOF 'Loop through all records in dataset
       'Read in initial AC_CATEGORY_NAME
         Act_Cat = rs(1)
       'Set field label, and visability parameters
         BHE_Ax_HOURS.Visible = True
         BHE_Ax_Sum.Visible = True
         BHE_Ax_HOURS_Label.Visible = True
         BHE_Ax_HOURS_Label.Caption = Acct_cat
       'Increment counter and Step to next record
       x = x + 1
       rs.MoveNext
     Loop

How do I dynamically name the control?  I tried "BHE_A"&x&"_HOURS" but this
does not work
George Nicholson - 20 Jun 2007 20:23 GMT
ohhhhh, soooo close:

frm.Controls("BHE_A"& x &"_HOURS")

(where frm is the Form you are working with. You could substitute Me if your
code is in that Form's module)

HTH,

>I have a form that contains twenty controls for # of hours, Sum of hours,
>and
[quoted text clipped - 26 lines]
> this
> does not work
Mymind - 21 Jun 2007 13:44 GMT
This worked well.  I ended up using the Me.

Thanks for all your help.

> ohhhhh, soooo close:
>
[quoted text clipped - 35 lines]
> > this
> > does not work
 
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.