How to protect user open more than one in 1 ms access in same time

  • Thread starter Thread starter wan
  • Start date Start date
W

wan

Pleasw help...
I have one ms access start open form, stand alone user and
only one pc. only one file.
How can i prevent user to open more than one ms access
program in same time I mean same file(it's same file mdb
but user open and open again)

Thank you very much
 
on start up of your main form:

dim Found as Boolean
With Application.FileSearch
.NewSearch
.LookIn = "C:\"
.SearchSubFolders = false
.FileName = "TEMPFILE.txt"
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles
End With
With Application.FileSearch
If .Execute() > 0 Then
Found = true
'TEMPFILE is found database is in use
docmd.quit ' close database
Else
Found = False
'no temp file found - database is not in use
Open "C:\TEMPFILE.txt" For Output As #1 ' Open
file for output.
Print #1, "Temp file for database open check" ' Print
text to file.
close #1 'close file
End If
End With

on close of main form:

If Found = False then
'delete source file
Kill "C:\TEMPFILE.txt"
end if

this is untested so may need to be changed slightly.
Theres probably a better way to do it

you could check for the .ldb file, and if this exists do
not open the database as it is in use.

HTH

Brian
 
Back
Top