MS Access VB Error 2220

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Tourless
Pro Scripter
Posts: 69
Joined: Wed Jun 14, 2017 1:53 am
Location: NY

MS Access VB Error 2220

Post by Tourless » Wed Mar 31, 2021 9:02 pm

Hi Folks,

I'm in the early stages of developing a new routine and the first thing I'm doing is opening a Microsoft Access DB (.accdb). There is a form load event that takes place when the file is open which looks to pull in a jpg image located on a network drive (T:\Images\no-image.jpg). When I open the DB with a manual double click, I provide login credentials and move on without error. When I try to launch the DB from my script the DB opens, I'm presented with the login dialog, I provide the credentials in my script and the DB opens. BUT, it opens with a Microsoft Visual Basic error 2220... "your DB can't open the file 'T:\Images\no-image.jpg'.

I've tried relaunching MacroScheduler as Admin, I've tried placing my Access DB in a folder on my C drive, at the root of my C drive, and desktop. I've tried RunProgram instead of ExecuteFile. I've checked file and folder permissions on the DB and image folder. I've run out of things to try.

Anyone else run into a problem like this and what did you do to fix it?

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: MS Access VB Error 2220

Post by mightycpa » Sat Apr 03, 2021 12:12 am

To run as admin, set RP_ADMIN to 1.
I've never run into that, but have you tried RunProgram using that setting?
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: MS Access VB Error 2220

Post by mightycpa » Sat Apr 03, 2021 12:43 am

Also, what about making sure the file exists using VB before you open the db and before you get the file? That way, you can narrow it down to path or permissions. You ought to assume your assumption that it obviously knows the path and display everything that you can.

You may also wish to run the dos whoami command to see the user that's running the db code.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

Tourless
Pro Scripter
Posts: 69
Joined: Wed Jun 14, 2017 1:53 am
Location: NY

Re: MS Access VB Error 2220

Post by Tourless » Tue Apr 06, 2021 7:11 pm

Thanks mighty. I've tried RP_ADMIN=1 and I've tried it with RunProgram. I know the file exists and only have this issue when launching from the macro. I've managed to work around it by adding a bit of code to a form load event...
Dim pic As String
pic = "T:\Drop-Images\Attached\no-image.jpg"
If Len(Dir(pic)) > 1 Then
Me.Image4.Picture = pic
Else
Me.Image4.Picture = ""
Me.Image4.Requery
End If
It works to suppress the error but I've like to get to the root of the issue if nothing than for my own peace of mind.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts