Runtime Error 2501 on acCmdImportAttachExcel (1 Viewer)

mrmozambique

Registered User.
Local time
Today, 11:58
Joined
May 20, 2009
Messages
16
Greetings, all.

I personally am running 2007, but a customer of mine is using 2003 (trying to get exact version). I have a label on a simple form that opens an import from Excel window (ImportAttachExcel). On my 2007 Access and nearly all others it works fine. However, one customer of mine running 2003 receives a runtime 2501 error as soon as they click the label. It seems that this normally happens when opening reports, but I can't find anything about this occurring when importing from Excel.

The code is super simple:

Code:
Private Sub  btnimport_Click()
DoCmd.RunCommand acCmdImportAttachExcel
End Sub
Any ideas? Thanks in advance from Bangkok!
 

Trevor G

Registered User.
Local time
Today, 05:58
Joined
Oct 1, 2009
Messages
2,341
Have you checked which References to which verssion have been set via the VBA screen.

You need to use Alt + F11 and then look a the tools menu and references, if you created the database in 2007 and send to someone who is using 2003 it is possible the 2007 references for Excel aren't available, but if they reset this to 2003 version it should correct the issue.

Access 2007 is Office 12
Access 2003 is Office 11

So you need to check if 12 is missing.
 

mrmozambique

Registered User.
Local time
Today, 11:58
Joined
May 20, 2009
Messages
16
Have you checked which References to which verssion have been set via the VBA screen.

You need to use Alt + F11 and then look a the tools menu and references, if you created the database in 2007 and send to someone who is using 2003 it is possible the 2007 references for Excel aren't available, but if they reset this to 2003 version it should correct the issue.

Access 2007 is Office 12
Access 2003 is Office 11

So you need to check if 12 is missing.

Thanks, Trevor. So if I'm looking through 2007 at these libraries, I won't see the 2003 Access (11.0) library, correct? I had a look at the exhaustive list and didn't see anything there that contained Access/Office 11.0. Regardless, I'll speak to my customer tomorrow and see if she can reset it. I appreciate the help.
 

SOS

Registered Lunatic
Local time
Yesterday, 21:58
Joined
Aug 27, 2008
Messages
3,517
You're trying to use an Access 2007 function with Access 2003. It isn't going to work as ImportAttachExcel does not exist in 2003.
 

mrmozambique

Registered User.
Local time
Today, 11:58
Joined
May 20, 2009
Messages
16
You're trying to use an Access 2007 function with Access 2003. It isn't going to work as ImportAttachExcel does not exist in 2003.

Good one, SOS. Here's my new code and it works fine (although a bit imperfect with the ErrHandler). The form error handler doesn't catch the 2501 error in this case as it happens outside of the form (browse dialog). When the user clicks Cancel in the browse dialogue, it still creates a 2501 although everything else seems to work. I'm going to assume that the only error that can happen w/ this one is the annoying 2501.


Code:
Private Sub lblimport_apr_file_Click()
On Error GoTo Err2501

Dim GetVersion As String
GetVersion = SysCmd(acSysCmdAccessVer)

If GetVersion <> "11.0" And GetVersion <> "10.0" And GetVersion <> "9.0" And GetVersion <> "8.0" Then
'This command only works in Access 2007
DoCmd.RunCommand acCmdImportAttachExcel
Else
'So we will replace it with this command for previous versions
DoCmd.RunCommand acCmdImport
End If

Err2501:
Resume Next

End Sub
 

Users who are viewing this thread

Top Bottom