A small program to monitor links between two databases ans stores status results in a table. Works fine as code from within Access 97. When I try to run the code after opening the database as an access application object an error message that the action was cancelled by the user appears
"Run time error 2501 The runcommand action was cancelled. e.g You used a DoCmd method and then clicked cancel in the dialogue box'
............oh no I didn't!
Perhaps the vba code is closing the object before the action has been completed? If so how can I prevent this? Thanks in advance!
Code segments attached,
VB6 code
Sub opencontrol()
Dim strDbName As String
strDbName = "C:\db6.mdb"
Set dbase = New Access.Application
dbase.OpenCurrentDatabase strDbName
dbase.DoCmd.RunCommand checkDatabaseX 'line run prior to problem
dbase.CloseCurrentDatabase 'is this the cause?
Set dbase = Nothing
End Sub
CALLed code on access 97 module as below:
This code runs fine from within access!
Sub checkDatabaseX()
Dim wrkJet As Workspace
Dim dbsToCheck As Database
Dim retval As Integer
Err.Clear
On Error GoTo faildbs
' Create Microsoft Jet Workspace object.
Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
' Open Database object from saved Microsoft Jet database
' not for exclusive use.
Set dbsToCheck = wrkJet.OpenDatabase("Y:\status monitor1.mdb", False)
‘send message status to table
send_status "message….", "from checkDatabase", "OK", Now
Set dbsToCheck = Nothing
Set wrkJet = Nothing
Exit Sub
faildbs:
send_status "a n other message", "from checkDatabase", "FAIL " & Err.Number, Now
Set dbsToCheck = Nothing
Set wrkJet = Nothing
End Sub
"Run time error 2501 The runcommand action was cancelled. e.g You used a DoCmd method and then clicked cancel in the dialogue box'
............oh no I didn't!
Perhaps the vba code is closing the object before the action has been completed? If so how can I prevent this? Thanks in advance!
Code segments attached,
VB6 code
Sub opencontrol()
Dim strDbName As String
strDbName = "C:\db6.mdb"
Set dbase = New Access.Application
dbase.OpenCurrentDatabase strDbName
dbase.DoCmd.RunCommand checkDatabaseX 'line run prior to problem
dbase.CloseCurrentDatabase 'is this the cause?
Set dbase = Nothing
End Sub
CALLed code on access 97 module as below:
This code runs fine from within access!
Sub checkDatabaseX()
Dim wrkJet As Workspace
Dim dbsToCheck As Database
Dim retval As Integer
Err.Clear
On Error GoTo faildbs
' Create Microsoft Jet Workspace object.
Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
' Open Database object from saved Microsoft Jet database
' not for exclusive use.
Set dbsToCheck = wrkJet.OpenDatabase("Y:\status monitor1.mdb", False)
‘send message status to table
send_status "message….", "from checkDatabase", "OK", Now
Set dbsToCheck = Nothing
Set wrkJet = Nothing
Exit Sub
faildbs:
send_status "a n other message", "from checkDatabase", "FAIL " & Err.Number, Now
Set dbsToCheck = Nothing
Set wrkJet = Nothing
End Sub