Runcommand error - command not available

B

Biggles

Hi

I am trying to automate my monthly backup process, and I need some
assistance. I am copying a replicated database and I want to make some
changes to the queries in the backup, to basically hard code the dates. I am
trying to issue a command to recover design master, with this code below, but
get Command not available at this time. When the backup database opens, I
hide the database window, but I can still get to the command. Any ideas?

Dim AccessApp As Application

Set AccessApp = CreateObject("Access.Application")
AccessApp.OpenCurrentDatabase BACKUPNAME

'Make this the master
Application.RunCommand acCmdRecoverDesignMaster

Note: This code is running from a different database. Also, as a side
note, is the method of opening the database above DAO, ADO or something I
understand even less?
 
R

RoyVidar

Biggles said:
Hi

I am trying to automate my monthly backup process, and I need some
assistance. I am copying a replicated database and I want to make some
changes to the queries in the backup, to basically hard code the dates. I am
trying to issue a command to recover design master, with this code below, but
get Command not available at this time. When the backup database opens, I
hide the database window, but I can still get to the command. Any ideas?

Dim AccessApp As Application

Set AccessApp = CreateObject("Access.Application")
AccessApp.OpenCurrentDatabase BACKUPNAME

'Make this the master
Application.RunCommand acCmdRecoverDesignMaster

Note: This code is running from a different database. Also, as a side
note, is the method of opening the database above DAO, ADO or something I
understand even less?

I wont pretend I know anything about replication, as it is at least 8 or
9 years since I struggled with it, but if your intention is to issue
a .RunCommand on the opened database, you need to issue it on the
opened databases application object. As you do it know, you're
issuing it on the current database - the one running the code.

Does this work any better?

AccessApp.OpenCurrentDatabase BACKUPNAME

'Make this the master
AccessApp.DoCmd.RunCommand acCmdRecoverDesignMaster
 
B

Biggles

That worked really well. If anyone else is stuck with replication, and needs
to do this, I did have to re open the database in code, since the Recover
Design Master command didn't open it like you expect it to.

Thanks Roy
 

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