Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MsgBox notification that DB is locked

Status
Not open for further replies.

Anubis3000

Programmer
Dec 20, 2004
52
US
Hi,

I have a question in regards to a networked database. I have created a system where an administrator can lock out all users from a network database. An administrator can lock out the database, and once locked, only the administrator can get back in (this is done by network username). Otherwise, the program just opens and closes.

My problem is that I want a message box to appear notfiying the users that the database is locked. If I do this using message boxes or pop up forms within access, then the database remains open until the user presses ok, therby defeating the purpose of the lockout.

I wanted to know is there anyway to open, close and then have a pop up message box?


Any suggestions would be appreciated. Thanks.
 
How did you lock the networked database? I am trying to figure that out since I have to make modifications on the fly!!!
 
The way I do it is to have a field in the tblIni called ExecCloseDown of type Boolean

( tblIni is a single record table of db wide values )


On startup a form is opened NON Visible and remains open for the whole of the life of the app.

That forms Timer event fires every minute 60000 timer units.
It then checks the value of tblIni.ExecCloseDown and if set it pops up a message saying "Self Destruct in 5 minutes - You have time to finish the task you are on "

It then sets timerCount to 300000 ( 5 mins )

When this expires it does a quick bit of tidying up then runs an Appication.Quit command.


One of the first things the form that auto runs on startup does is to check that tblIni.ExecCloseDown is false.
If it is not then it then opens a form that tells the user about the closedown flag and says "Self Destruct in 10 seconds"
( Members of the "Administrators" group are given the option to reset the flag instead )
That form has a timer set to one second intervals that counts down the seconds.

When seconds = 0 a big red form opens that says BANG then I call Application.QUIT


'ope-that-'elps.

G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
I was thinking that one way to implement a message box notifying the database is locked is to use some kind of messagebox dll

(similar to the function aht_apiGetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (OFN As tagOPENFILENAME))

This way, access does not have to be open in order for the message box to pop up and stay on the screen, which is useful since i am opening and closing access and then putting up a pop up message.

Does anyone know or have code for a message box dll or api?
 
It does run asynchronously.

Code:
Shell "C:\WINNT\System32\WScript.exe sPath\sName.vbs"

The shell command runs asynchronously, so the database is already closed by the time the user clicks on the OK button.

Here is the text of my .VBS file:

Code:
MsgBox "Admin lock-out pending for database maintenance. Entry not permitted at this time.", vbOKOnly, "DB Maintenance In Progress"

I check to see if the currently logged in user (to the machine via Novell) is enabled for DB maintenance by checking an .INI file that I constructed. If your ID appears in the file, you can get in. I could have kept that information in Access, but that could lead to a situation where you can't get into the database at all because you are not enabled, or somehow got deleted from the table.
 
This seems like a good idea, but I was wondering if there is some way to do this without writing a .vbs file.

The problem with this solution is that the file path to the .vbs must be specified each time the database is moved or put onto a new machine, which could be a problem for my users.

Is there a way to either somehow "bond" the .vbs file to the .mdb access file? Or there is another solution? Thnx again.
 
You could just count on the .vbs file being in the same path as your database...

Code:
With Application.CurrentProject
   sMyVBSFile = .path & "\MyVBS.vbs"
End With

That does not "graft" the .vbs file to your database, but it is fairly dynamic that you could put the database anywhere on the user's machine so long as you put the .vbs file in the same location.

Alternately, you could test for the existence of the .vbs file in the same path as the database, and if it doesn't exist write it based on information contained in your database.

Code:
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim f As Object, ts As Object
Dim sFile As String

With Application.CurrentProject
    sFile = .Path & "\Test.vbs"
    If Dir(sFile) <> "Test.vbs" Then
        Set ts = CreateObject("Scripting.FileSystemObject").createtextfile(sFile)
        ts.write "MsgBox " & Chr$(34) & "Admin lock-out " & _
                  "pending for database maintenance. " & _
                  "Entry not permitted at this time." & _
                  Chr$(34) & ", vbOKOnly, " & Chr$(34) & _
                  "DB Maintenance In Progress" & Chr$(34)
        ts.Close
        Set ts = Nothing
    End If
    If Dir("c:\winnt\system32\wscript.exe") = "wscript.exe" Then
        Shell "c:\winnt\system32\wscript.exe" & sFile
    ElseIf Dir("c:\windows\system32\wscript.exe") = "wscript.exe" Then
        Shell "c:\windows\system32\wscript.exe " & sFile
    End If
End With

The script for the file could be kept in a table somewhere that houses database INI settings or configuration arguments.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top