notconfident
Programmer
I set up an Activity Table (TestTable) which logs various details as I open/close the database by calling the Function below. This worked ok until I wanted to copy the database to a laptop for remote use and then back to the office PC with this added to the Activity Table. I read that you cannot copy easily an open database so my solution was to produce a command button which opens another database (CopyDatabase) then close itself (MainDatabase). This CopyDatabase copies the MainDatabase(now closed)to a networked laptop then re-opens the MainDatabase and closes itself. After the evening on the laptop the same button in the MainDatabase is used (with flags in a table to show which way to copy)to now copy the MainDatabase from the laptop to the PC with the similar procedure of opening the CopyDatabase, closing the MainDatabase, copying the MainDatabase from laptop to PC, re-opening the MainDatabase and closing the CopyDatabase.
The procedure works and the Activity table is updated to show that the copy to the laptop is completed but there is no more entries in the Activity Table to show it copied back to the PC or even opening and closing.
For testing I added the Message Boxes which show the activities being added to the table at every step but they are all lost when the table is read at the end of the procedure.
Any ideas?? I have been Googling for a week now with no success.
Function Activity_TestTable(strAct)
Dim dbs As Database
Dim rstTest As Recordset
Set dbs = CurrentDb()
Set rstTest = dbs.OpenRecordset("TestTable", dbOpenTable)
rstTest.MoveLast
MsgBox "Data in recordset before with = " & rstTest!Activity & vbCrLf & _
"In Prog" & CurrentDb.Name
With rstTest
'.MoveLast
.AddNew
!Activity = strAct
!Activitydate = Now()
!DBsize = FileLen(CurrentDb.Name) / 1024
!MachineName = Environ("COMPUTERNAME")
.Update
.Bookmark = .LastModified
MsgBox "Data in recordset after update = " & !Activity
End With
rstTest.Close
End Function
The procedure works and the Activity table is updated to show that the copy to the laptop is completed but there is no more entries in the Activity Table to show it copied back to the PC or even opening and closing.
For testing I added the Message Boxes which show the activities being added to the table at every step but they are all lost when the table is read at the end of the procedure.
Any ideas?? I have been Googling for a week now with no success.
Function Activity_TestTable(strAct)
Dim dbs As Database
Dim rstTest As Recordset
Set dbs = CurrentDb()
Set rstTest = dbs.OpenRecordset("TestTable", dbOpenTable)
rstTest.MoveLast
MsgBox "Data in recordset before with = " & rstTest!Activity & vbCrLf & _
"In Prog" & CurrentDb.Name
With rstTest
'.MoveLast
.AddNew
!Activity = strAct
!Activitydate = Now()
!DBsize = FileLen(CurrentDb.Name) / 1024
!MachineName = Environ("COMPUTERNAME")
.Update
.Bookmark = .LastModified
MsgBox "Data in recordset after update = " & !Activity
End With
rstTest.Close
End Function