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

Tip: Looking for answers? Try searching our database.

UNDO to protect contents

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David - 29 Jan 2005 00:47 GMT
I am using Access 2002.

I have a main form with 2 sub forms.  I would like the user to not be able
to make changes to the main form or the subforms unless they are the
"Author".  I thought I figured it out, but.........  the UNDO action is
taken, message box is shown correctly, user clicks ok, and then the user can
edit/change and navigate to any field.  It works well on the FORMS's before
update, but I want the user to see the msgbox as soon as they type (if they
are not authorized).  Here is my code in the ON DIRTY event, any idea?

'If the user is not the Analyst and not an Author msgbox will display

If Me.cbo_Analyst <> Forms![Temp].Modify_By Then

   If Forms![Temp].[strAccess] <> "Author" Then

Undo
MsgBox "You do not have Access to modify this Project"
Exit Sub
Else

Me.Modify_Date = Date
Me.Modify_By = Forms![Temp].[Modify_By]
Forms![Temp].[SR] = Me.SR

   End If
End If
'********************************************************
John Vinson - 29 Jan 2005 02:34 GMT
>I have a main form with 2 sub forms.  I would like the user to not be able
>to make changes to the main form or the subforms unless they are the
>"Author".

I'd suggest setting the Form's AllowUpdates event to True or False in
its Load event, based on the identity of the author and the user.

                 John W. Vinson[MVP]    
David - 29 Jan 2005 17:17 GMT
Thank you John,
Simple and effective.

> >I have a main form with 2 sub forms.  I would like the user to not be able
> >to make changes to the main form or the subforms unless they are the
[quoted text clipped - 4 lines]
>
>                   John W. Vinson[MVP]    
B. Comrie - 29 Jan 2005 08:10 GMT
Here is a cool trick that you don't have to change data bindings at all

Enter an * in the tag property of the controls you want to lock/un-lock
To use the Sub...

If This <> That then LockForm(True) Else LockForm(False)

Private Sub LockForm(ByVal Mode As Boolean)
On Error GoTo errTrap
Dim ctrl As Control
For Each ctrl In Me.Controls
If ctrl.Tag = "*" Then ctrl.Locked = Mode
Next
If Mode = True then Me.Caption = "Data is Read Only"
Exit Sub
errTrap:
MsgBox Err.Number & " " & Err.Description
End Sub

B Comrie
http://www.codewidgets.com

> I am using Access 2002.
>
[quoted text clipped - 24 lines]
> End If
> '********************************************************
 
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.