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 2008

Tip: Looking for answers? Try searching our database.

Locking/Enabling Combo Box in Form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BMoroneso - 30 Jun 2008 17:07 GMT
I want to lock all the data fields in a form when I open it, leaving only the
filter combo boxes available for use.

Three of the data fields are combo boxes (InsurerID, TypeID, and ProdCatID).
The code I've used is below.

DoCmd.OpenForm "frmProducts", acNormal, "", "", , acNormal
       Forms!frmProducts.ProductName.SetFocus
       Forms!frmProducts!InsurerID.Enabled = False
       Forms!frmProducts!TypeID.Enabled = False
       Forms!frmProducts!ProdCatID.Enabled = False
       Forms!frmProducts!ProductName.Locked = True
       Forms!frmProducts!DateIntroduced.Locked = True
       Forms!frmProducts!DateRetired.Locked = True
       Forms!frmProducts!frmCommSetup.Locked = True
       
The enabled = false setting works for the first two combo boxes, but not the
third, and the locked = true setting doesn't work for any of them.  The error
message returned is "Object doesn't support this property or method."  But,
everything I have read online and in books says it should work with no
problems...

Any advice is appreciated!!
Arvin Meyer [MVP] - 30 Jun 2008 17:13 GMT
Here is the code to lock all the fields. As you can see, by using the TAG
property of a field, you can fine tune to only specific controls:

http://www.datastrat.com/Code/LockIt.txt
Signature

Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

>I want to lock all the data fields in a form when I open it, leaving only
>the
[quoted text clipped - 24 lines]
>
> Any advice is appreciated!!
BMoroneso - 30 Jun 2008 17:31 GMT
Thanks for the code.  I will try it out.  Do you by chance know why the
.locked and/or .enabled properties are not working with the code that I wrote?
Thanks,
Becky

> Here is the code to lock all the fields. As you can see, by using the TAG
> property of a field, you can fine tune to only specific controls:
[quoted text clipped - 28 lines]
> >
> > Any advice is appreciated!!
Arvin Meyer [MVP] - 30 Jun 2008 18:57 GMT
My guess is that the first one that fails doesn't allow disabling or
locking. As soon as the code breaks, nothing else will work either. You
could try commenting out the first line that breaks, then rerunning the code
to see if anything else breaks. Only deal with the ones that break.
Signature

Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

> Thanks for the code.  I will try it out.  Do you by chance know why the
> .locked and/or .enabled properties are not working with the code that I
[quoted text clipped - 36 lines]
>> >
>> > Any advice is appreciated!!
BMoroneso - 30 Jun 2008 21:42 GMT
It's just the combo boxes with sql as a source that break the code.  I've
been through the 'commenting out' process and those are the only ones that
cause trouble.  Other combo boxes with a value list work just fine.

> My guess is that the first one that fails doesn't allow disabling or
> locking. As soon as the code breaks, nothing else will work either. You
[quoted text clipped - 40 lines]
> >> >
> >> > Any advice is appreciated!!
BMoroneso - 30 Jun 2008 17:40 GMT
Also, I must be doing something wrong because the code didn't lock any of the
controls.  Help?

> Here is the code to lock all the fields. As you can see, by using the TAG
> property of a field, you can fine tune to only specific controls:
[quoted text clipped - 28 lines]
> >
> > Any advice is appreciated!!
Arvin Meyer [MVP] - 30 Jun 2008 18:59 GMT
Set a breakpoint at the first line of code, and step through the code,
commenting out lines that error out.
Signature

Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

> Also, I must be doing something wrong because the code didn't lock any of
> the
[quoted text clipped - 34 lines]
>> >
>> > Any advice is appreciated!!
 
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.