[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 283
  • Last Modified:

Block access to MS access at night time with error message

Here is the question: How to block access to MS access at night time with an error message?
0
SSupreme
Asked:
SSupreme
  • 3
1 Solution
 
SSupremeAuthor Commented:
Surely, it is for single .mdb file, not for whole application.
0
 
JVWCCommented:
Depending on how secure you want this to be...
A simple method:
This code in a form, set as the default form for opening.
One textbox on the form [text0] set to =time()
Or simply test against the time component of Now()

Can be bypassed using shift key
JC
Private Sub Form_Load()
If Me.Text0 < #5:00:00 PM# And Me.Text0 > #6:00:00 AM# Then
    DoCmd.OpenForm ("myNormalOpeningFormName")
    DoCmd.Close acForm, Me.Name, acSaveNo

Else
    If MsgBox("It's dark outside" & vbCr & "Closing App", , "Can't work in the dark!") = vbOK Then
    DoCmd.Close acForm, Me.Name, acSaveNo
    Application.Quit
    End If

End If

End Sub

Open in new window

0
 
SSupremeAuthor Commented:
Not exactly what I am looking for.
I think it should be in module.
Like this one I already have:
Function IsLoaded(ByVal strFormName As String) As Integer
    
    Const conObjStateClosed = 0
    Const conDesignView = 0
    
    If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
        If Forms(strFormName).CurrentView <> conDesignView Then
            IsLoaded = True
        End If
    End If
    
End Function

Open in new window

0
 
SSupremeAuthor Commented:
Actually, it is possible solution.
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now