Access not closing after VBA procedure runs.

T

Tod

I'm not sure if this is the right NG but I'll start here.

My database has a link to a table in a live database. I
have a macro that runs a function that runs a procedure
each night. The procedure updates one of my static tables
using new data from the linked table.

For almost a year it has run properly. So well in fact
that I never have to worry about it, until now. It seems
that lately the code runs, but the database is left open.
So there is a lock file in the folder and MSACCESS still
running in the Task Manager.

I haven't changed anything in the macro, the function, or
the procedure. I tried compacting and repairing the
database. No change. Any idea what this could be?

Oh also, here's my code. The names have been changed to
protect the guilty. <g>

'The macro runs this function
Function UpdateProcs()
'The function runs these two procedures
Call DailyDataAppend
Call DailyStaticAppend
End Function

Sub DailyDataAppend()
Dim fso As Object
Dim f As Object

'This query deletes all data in the table
DoCmd.OpenQuery "qryDeletetblDateCreated"
'This query appends all new data to the table
DoCmd.OpenQuery "qryAppendtblDateCreated"

'This opens a log file and creates an entry
Set fso = CreateObject("Scripting.FileSystemObject")
Set txtStream = fso_OpenTextFile("C:\View\Logs\View
Log.txt", 8)
txtStream.WriteLine (vbCrLf & Now & ": tblDateCreated
updated")
txtStream.Close

Set txtStream = Nothing
Set f = Nothing
Set fso = Nothing

End Sub

Sub DailyStaticAppend()
Dim fso As Object
Dim f As Object

'This query deletes all data this month
DoCmd.OpenQuery "qryDeleteStatic"
'This query appends all new data this month
DoCmd.OpenQuery "qryAppendStatic"

'This opens the log file and creates an entry
Set fso = CreateObject("Scripting.FileSystemObject")
Set txtStream = fso_OpenTextFile("C:\View\Logs\View
Log.txt", 8)
txtStream.WriteLine (vbCrLf & Now & ": tblStatic
updated")
txtStream.Close

Set txtStream = Nothing
Set f = Nothing
Set fso = Nothing

End Sub
 

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

Top