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 / March 2005

Tip: Looking for answers? Try searching our database.

Accessing a control using a db field name...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brad Pears - 08 Mar 2005 21:33 GMT
I have a table in which are stored control names found on a form.

I want to loop through the records in the table and "enable" the control
names found in the db table...

How can this be done?

Thanks,

Brad
Rob Oldfield - 08 Mar 2005 22:27 GMT
dim db as database
dim rs as recordset
set db=currentdb
set rs=db.openrecordset("TableName")
rs.movefirst
do while not rs.eof
   me(rs!FieldName).enabled=true
   rs.movenet
loop
rs.close
set db=nothing

> I have a table in which are stored control names found on a form.
>
[quoted text clipped - 6 lines]
>
> Brad
Brad Pears - 09 Mar 2005 15:58 GMT
Thanks... One additional question...

If the conmtrols I am setting are on a subform would the syntax to set the
property be something like this...

Forms![frmPricing]![frmMenuItems].Form.RS!ItemControlName.Enabled = True

where frmPricing is the main form and frmMenuItems is the subform and
RS!ItemControlName is the DB fieldname containing the name of the control?

Thanks,

Brad
> dim db as database
> dim rs as recordset
[quoted text clipped - 18 lines]
>>
>> Brad
Brad Pears - 09 Mar 2005 16:24 GMT
Thanks... Now one additional question...

I am having problems with your syntax and maybe the fact that the controls I
am trying to set are on a subform as opposed to being on the current form...

Here is the syntax I am using...

Forms![frmPricing]![frmMenuItems].Form.RS!ItemControlName.Enabled = True

where "frmPricing" is the main form, "frmMenuItems" is the subform and
RS!ItemControlName is the DB fieldname containing the name of the control.

When I run the code I get an "Application-defined or object-defined error".
In debug, if I substitute the RS!ItemControlName with the actual field
name - it works fine. It appears that it is not obtaining the actual
controls name from RS!ItemControlName and substituting it into the command
syntax properly...

Any ideas on this one?

Thanks,

Brad

> dim db as database
> dim rs as recordset
[quoted text clipped - 18 lines]
>>
>> Brad
Rob Oldfield - 09 Mar 2005 18:38 GMT
me.SubFormControlName(rs!FieldName).enabled=true

> Thanks... Now one additional question...
>
[quoted text clipped - 42 lines]
> >>
> >> Brad
 
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.