DoCmd.TransferDatabase run-time error 2501

M

Matt Tatham

I'm hoping someone out there can help me with this.

I have several databases created using Access 2000. I'm using a transfer
utility developed by a contractor of some years ago for our company to update
the production databases we have at remote locations. I have used it without
error or problem for two years and it started hanging up, giving me this
error:

Run-time error '2501'
TransferDatabase was cancelled

I've been running through the knowledge base and online help to try and find
out why this was occurring. All I've been able to do so far is trap the
error and exit gracefully. My code originally looked like this:

Private Sub Command0_Click()

MsgBox "start"
DoCmd.TransferDatabase (acExport), "Microsoft Access", "H:\MfgInfo.mdb",
acModule, "Global", "Global", False
DoCmd.TransferDatabase (acExport), "Microsoft Access", "H:\MfgInfo.mdb",
acForm, "Schedule", "Schedule", False
MsgBox "finished"

End Sub

Using the help I found online, I added error trapping thusly:

Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

MsgBox "start"
DoCmd.TransferDatabase (acExport), "Microsoft Access", "\H:\MfgInfo.mdb",
acModule, "Global", "Global", False
DoCmd.TransferDatabase (acExport), "Microsoft Access", "H:\MfgInfo.mdb",
acForm, "Schedule", "Schedule", False

MsgBox "finished"

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
If Err.Number = 2501 Then
MsgBox "IS 2501"
Resume Exit_Command0_Click
Else
MsgBox "NOT 2501"
Resume Exit_Command0_Click
End If

End Sub

I can now see when the error occurs and my program doesn't crash, but I have
zero information on why the error is occurring and how I can resolve it so
that the TransferDatabase can actually function.

Any help is greatly appreciated.

Matt Tatham
 
D

Dorian

Maybe drive H: does not exist on the computer running this.
Never use mapped drive letters in an application, always use a path to the
server e.g.
\\servername\foldername
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
R

ryguy7272

The run-time error 2501 error means something was cancelled; some operation
was canceled. In this case, it is the TransferDatabase operation. Something
that should exist probably does not exist. What changed recently? Think
about it. Also, go into edit mode, Alt+F11, set some break points, click the
'Command0' button and f* through the code. Notice where the error occurs.
That's your answer.
 

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