G
Guest
HERE IS MY CODE AND MY PROBLEMS ARE DESCRIBED WITHIN IN CAPS
WITH #1- #2- #3- PRECEDING THE QUESTIONS
I WOULD REALLY APPRECIATE SOME GUIDANCE.
THANK YOU VERY MUCH..
--------------------------------------
Private Sub DuplicateDB_Click()
On Error GoTo Err_DuplicateDB_Click
Dim dbs As String
Dim lDbFileName As String
Dim appAccess As Object
#1-NOT SURE IF I'VE USE THIS CORRECTLY, I DON'T SEE ANY HOURGLASS
DoCmd.Hourglass True
lDbFileName = "D:\Dev\DB1.ldb"
dbs = "D:\Dev\DB1.mdb" 'Local Testing Location
If Len(Dir(lDbFileName)) > 0 Then
On Error Resume Next
Kill lDbFileName
If Err.Number = 0 Then 'delete was successful, file not in use
Call RefreshData 'CALL THIS PROCEDURE TO repopulate tables
Call CompactDb 'CALL THIS PROCEDURE TO COMPACT THE NEWLY
UPDATED ADHOC DB
End If
On Error GoTo Err_DuplicateDB_Click
Else
Call RefreshData 'CALL THIS PROCEDURE TO repopulate tables
Call CompactDb 'CALL THIS PROCEDURE TO COMPACT THE NEWLY
UPDATED ADHOC DB
End If
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase dbs
appAccess.Visible = True
#2-TO THIS POINT THINGS SEEM TO BE WORKING BUT AS SOON AS THE EXIT SUB
COMPLETES THE DB CLOSES
AS I WAS WRITING THIS I REALIZED MAYBE I COULD USE SOMETHING LIKE
APPACTIVATE, IF THAT IS THE ANSWER
PLEASE SHOW ME HOW, IF NOT PLEASE TELL ME WHAT IS...
Exit_DuplicateDB_Click:
Exit Sub
Err_DuplicateDB_Click:
MsgBox Err.Description
Resume Exit_DuplicateDB_Click
End Sub
--------------------------------------
Private Sub RefreshData()
Dim db As DAO.Database
Set db = OpenDatabase("D:\Data\DBA\Dev\Conv
IrmaB2003\AdhocDB\IrmaB_AdhocReporting.mdb", True)
On Error GoTo Err_RefreshData
'THIS MODULE WILL RUN ALL THE DELETE AND APPEND QUERIES THAT ARE USED TO
REFRESH THE TABLE DATA
db.Execute "qd_ACH Detail", DAO.dbFailOnError
15 OTHER LINES LIKE THAT
db.Execute "qa_L_ACH Detail", DAO.dbFailOnError
SAME HERE
db.Close
Exit_RefreshData:
Exit Sub
Err_RefreshData:
MsgBox Err.Description
Resume Exit_RefreshData
End Sub
--------------------------------------
Sub CompactDb()
On Error GoTo Err_CompactDb
' This statement creates a compact version of the database
DBEngine.CompactDatabase "\\UNCPATH\db1.mdb", "\\UNCPATH\tmp.mdb"
'***** Found that using the Declaration procedure caused a *****
'***** locking issue when the compact command was issued *****
'Dim Olddb As String
'Dim Newdb As String
' Olddb = "D:\Dev\DB1.mdb"
' Newdb = "D:\Dev\tmp.mdb"
' DBEngine.CompactDatabase Olddb, Newdb
'Now lets take a few seconds to let everything settle, PAUSE.
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
Finish = Timer
'DELETE THE ORIGINAL DB AND RENAME THE COMPACTED DB TO THE ORIGINAL NAME
'The BAT file called here will first test if there is a backup copy of the
previously
'Compacted db, then rename the reporting/adhoc db as a backup copy, then
rename the newly
'Compacted db to the reporting/adhoc db name.
#3-I think need to use something like this
AppActivate shell("D:\Dev\RenComp.bat", 1)
in order for the module to wait until the bat file completes before
returning to the
calling mod to open the DB, DO I HAVE THE CORRECT SYNTAX ABOVE, AND IS THIS
THE PROPER USAGE??
this is what I currently have in place
Shell "D:\Dev\RenComp.bat", 1
Exit_CompactDb:
Exit Sub
Err_CompactDb:
MsgBox Err.Description
Resume Exit_CompactDb
End Sub
WITH #1- #2- #3- PRECEDING THE QUESTIONS
I WOULD REALLY APPRECIATE SOME GUIDANCE.
THANK YOU VERY MUCH..
--------------------------------------
Private Sub DuplicateDB_Click()
On Error GoTo Err_DuplicateDB_Click
Dim dbs As String
Dim lDbFileName As String
Dim appAccess As Object
#1-NOT SURE IF I'VE USE THIS CORRECTLY, I DON'T SEE ANY HOURGLASS
DoCmd.Hourglass True
lDbFileName = "D:\Dev\DB1.ldb"
dbs = "D:\Dev\DB1.mdb" 'Local Testing Location
If Len(Dir(lDbFileName)) > 0 Then
On Error Resume Next
Kill lDbFileName
If Err.Number = 0 Then 'delete was successful, file not in use
Call RefreshData 'CALL THIS PROCEDURE TO repopulate tables
Call CompactDb 'CALL THIS PROCEDURE TO COMPACT THE NEWLY
UPDATED ADHOC DB
End If
On Error GoTo Err_DuplicateDB_Click
Else
Call RefreshData 'CALL THIS PROCEDURE TO repopulate tables
Call CompactDb 'CALL THIS PROCEDURE TO COMPACT THE NEWLY
UPDATED ADHOC DB
End If
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase dbs
appAccess.Visible = True
#2-TO THIS POINT THINGS SEEM TO BE WORKING BUT AS SOON AS THE EXIT SUB
COMPLETES THE DB CLOSES
AS I WAS WRITING THIS I REALIZED MAYBE I COULD USE SOMETHING LIKE
APPACTIVATE, IF THAT IS THE ANSWER
PLEASE SHOW ME HOW, IF NOT PLEASE TELL ME WHAT IS...
Exit_DuplicateDB_Click:
Exit Sub
Err_DuplicateDB_Click:
MsgBox Err.Description
Resume Exit_DuplicateDB_Click
End Sub
--------------------------------------
Private Sub RefreshData()
Dim db As DAO.Database
Set db = OpenDatabase("D:\Data\DBA\Dev\Conv
IrmaB2003\AdhocDB\IrmaB_AdhocReporting.mdb", True)
On Error GoTo Err_RefreshData
'THIS MODULE WILL RUN ALL THE DELETE AND APPEND QUERIES THAT ARE USED TO
REFRESH THE TABLE DATA
db.Execute "qd_ACH Detail", DAO.dbFailOnError
15 OTHER LINES LIKE THAT
db.Execute "qa_L_ACH Detail", DAO.dbFailOnError
SAME HERE
db.Close
Exit_RefreshData:
Exit Sub
Err_RefreshData:
MsgBox Err.Description
Resume Exit_RefreshData
End Sub
--------------------------------------
Sub CompactDb()
On Error GoTo Err_CompactDb
' This statement creates a compact version of the database
DBEngine.CompactDatabase "\\UNCPATH\db1.mdb", "\\UNCPATH\tmp.mdb"
'***** Found that using the Declaration procedure caused a *****
'***** locking issue when the compact command was issued *****
'Dim Olddb As String
'Dim Newdb As String
' Olddb = "D:\Dev\DB1.mdb"
' Newdb = "D:\Dev\tmp.mdb"
' DBEngine.CompactDatabase Olddb, Newdb
'Now lets take a few seconds to let everything settle, PAUSE.
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
Finish = Timer
'DELETE THE ORIGINAL DB AND RENAME THE COMPACTED DB TO THE ORIGINAL NAME
'The BAT file called here will first test if there is a backup copy of the
previously
'Compacted db, then rename the reporting/adhoc db as a backup copy, then
rename the newly
'Compacted db to the reporting/adhoc db name.
#3-I think need to use something like this
AppActivate shell("D:\Dev\RenComp.bat", 1)
in order for the module to wait until the bat file completes before
returning to the
calling mod to open the DB, DO I HAVE THE CORRECT SYNTAX ABOVE, AND IS THIS
THE PROPER USAGE??
this is what I currently have in place
Shell "D:\Dev\RenComp.bat", 1
Exit_CompactDb:
Exit Sub
Err_CompactDb:
MsgBox Err.Description
Resume Exit_CompactDb
End Sub