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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check if database is open 2

Status
Not open for further replies.

BazzaRich

Programmer
Mar 14, 2007
3
GB
Need some simple code to check to see if database is open.



 
BazzaRich,
what kind of db? if ms access the just check to see if there is an .ldb file in the directory.
regards,
longhair
 
The obvious is always the hardest to look for!

Thank you, any simple vba code for checking to see if file exixts?
 
BazzRich,
not exactly what you need to do but should get you started:
Code:
Set fs = Application.FileSearch
With fs
    .LookIn = "c:\test"
    .FileType = msoFileTypeExcelWorkbooks
    .Execute
End With
For i = 1 To fs.FoundFiles.Count
    msgbox fs.FoundFiles(i)
Next i
just look in vba help for filesearch and adjust what you need to search for.
regards,
longhair
 
Or simpler:
If Dir("\path\to\dir\*.ldb") <> "" Then
MsgBox "Database is open"
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top