ldb Open

D

Douglas J. Steele

To only have your code run when the file doesn't exist, you need

If Me.TxtFile = 0 Then

The Dir function returns the file name without its path if the file exists,
or a zero-length string ("") if the file doesn't exist.
 
D

DS

I'm running this code that compacts and repairs my backend the problem
is the ldb always seems to be open, there are no users on and no forms
are open, only the one I'm running the code from. Any reason for this?

Me.TxtFile = Len(Dir$("C:\PROSERV\DB\Data.ldb"))
If Me.TxtFile >= 1 Then
Name "C:\PROSERV\DB\Data.mdb" As "C:\PROSERV\DB\OldData.mdb"
DBEngine.CompactDatabase "C:\PROSERV\DB\OLDData.mdb",
"C:\PROSERV\DB\Data.mdb"
Kill "C:\PROSERV\DB\OldData.mdb"
DoCmd.OpenForm "Form2"
ElseIf Me.TxtFile = 0 Then
End If

Thanks
DS
 
D

DS

Douglas said:
To only have your code run when the file doesn't exist, you need

If Me.TxtFile = 0 Then

The Dir function returns the file name without its path if the file exists,
or a zero-length string ("") if the file doesn't exist.
Your Right.
Thanks Douglas'
DS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Compacting BackEnd 4
Run-time error 3061 excel to access 1
DIR - Excel VBA function 1
find file exists 1
Is File Open 8
Len(Dir..... syntax 4
button and path question 5
Error 2471 10

Top