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 / November 2006

Tip: Looking for answers? Try searching our database.

Lock Form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mattc66 - 18 Nov 2006 00:05 GMT
On the suggestion of another thread I placed the word LOCK on each of my
controls TAG.

On the Form event Current I placed the following code. I get run-time error
438 Object doesn't support this property.

What I am trying to do is Lock all items on my form if the "EDI_Complete"
Check box is TRUE.

Can anyone offer me a suggested solution?

Thanks
Matt

Private Sub Form_Current()
   
    Dim ctl As Control
For Each ctl In Me.Controls
   If ctl.Tag = "LOCK" Then
       If Me.EDI_Complete = True Then
           ctl.Locked = True
           ctl.ForeColor = vbBlue
       Else
           ctl.Locked = False
           ctl.ForeColor = vbGreen
       End If
   End If
Next ctl
 

End Sub

Signature

Matt Campbell
mattc (at) saunatec [dot] com

Douglas J. Steele - 18 Nov 2006 03:39 GMT
I don't believe every control has a Tag property. You'll have to put in
error trapping to determine which control(s) cause the error, and ensure
that you don't look at the Tag property for those controls. (Look at the
ControlType property if you need to eliminate certain controls)

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> On the suggestion of another thread I placed the word LOCK on each of my
> controls TAG.
[quoted text clipped - 27 lines]
>
> End Sub
Marshall Barton - 18 Nov 2006 16:12 GMT
>I don't believe every control has a Tag property. You'll have to put in
>error trapping to determine which control(s) cause the error, and ensure
>that you don't look at the Tag property for those controls. (Look at the
>ControlType property if you need to eliminate certain controls)

I think all the Access controls have the Tag property,
though some ActiveX controls might not.

However, there are some controls that do not have a Locked
(e.g. label) or ForeColor (e.g. checkbox) property.

If a control does not have the Locked property, it should
not be included in the set of controls with "LOCK" in the
Tag property.

An alternative is to use different values in the Tag
property.  E,g, "LOCK" for controls that need to be locked
and "FORE" for controls that need to change color.  For
those controls that need both, set their Tag to "LOCK;FORE"
The code could then look like:

For Each ctl In Me.Controls
   If ctl.Tag Like  "*LOCK*" Then
        ctl.Locked = Me.EDI_Complete
    End If
    If ctl.Tag Like  "*FORE*" Then
       If Me.EDI_Complete = True Then
           ctl.ForeColor = vbBlue
       Else
           ctl.ForeColor = vbGreen
       End If
   End If

Error handling is a good idea regardless of how the problem
is addressed.

Signature

Marsh
MVP [MS Access]

Douglas J. Steele - 19 Nov 2006 12:59 GMT
>>I don't believe every control has a Tag property. You'll have to put in
>>error trapping to determine which control(s) cause the error, and ensure
[quoted text clipped - 31 lines]
> Error handling is a good idea regardless of how the problem
> is addressed.

Yeah, I believe you're correct, Marsh.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

mattc66 - 20 Nov 2006 18:01 GMT
That works thanks - How would I lock a subform?

>>I don't believe every control has a Tag property. You'll have to put in
>>error trapping to determine which control(s) cause the error, and ensure
[quoted text clipped - 31 lines]
>Error handling is a good idea regardless of how the problem
>is addressed.

Signature

Matt Campbell
mattc (at) saunatec [dot] com

Marshall Barton - 26 Nov 2006 23:52 GMT
You can lock the entire subform by locking the subform
control.
Signature

Marsh
MVP [MS Access]

>That works thanks - How would I lock a subform?
>
[quoted text clipped - 33 lines]
>>Error handling is a good idea regardless of how the problem
>>is addressed.
 
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.