Example BeforeJobOpened - Reset access based on job status

Scenario: A user requests a job is opened for update. Business rules apply to determine whether the job can be updated based upon whether it is finalised or not.

Copy

Example BeforeJobOpened - Reset access based on job status

'-------------------------------------------------------------------------------

' Sub PROUDF3 Called just before editing a job. 

'-------------------------------------------------------------------------------

Sub ProUDF3()

Dim dtDate

        dtDate = CDate(0)

        dtDate = CDate(clsBDProfjob.Profjob.Finalised)

        If dtDate >= #01/01/1900# Then

                bAccess = CheckStaffRights (clsSecurity.Username, "ADMIN")

                If bAccess Then

                        If Form.AccessLevel = 0 Then

                                lI = vbNo

                        Else

                                lI = MsgBox ("job has been finalised, any changes will affect a completed job" & vbCrLf & _

                                        "open readonly mode", vbYesNo+vbQuestion, "Warning")

                        End If

                        If lI = vbYes Then

                                Form.AccessLevel = 0

                        End If

                Else

                        If Form.Accesslevel = 0 Then

                        Else

                                MsgBox "job has been finalised, setting to readonly mode", vbOKOnly+vbExclamation, "Warning"

                                Form.AccessLevel = 0

                        End If

                End If

        End If

End Sub