Link to home
Start Free TrialLog in
Avatar of gdunn59
gdunn59

asked on

Getting the Error "User-defined type not defined" in MS Access 2013

I'm getting the following error:

User-defined type not defined

On the following line of code:

Function AddEmailInspection(rstInspections As ADODB.Recordset, rstExceptions As ADODB.Recordset, mi As Outlook.MailItem, Optional strManualPdfPath As String = "") As Long

I'm sure it has something to do with the References, I've tried several of the references and still getting the error.  I'm not sure what reference to use for MS Access 2013 VBA.

Thanks,

gdunn59
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

add to your references

Microsoft outlook xx object library
Microsoft activeX data objects 6.1 library
I'd suggest you add a lower version of ADO, like 2.5. Access will upsize that reference as needed, but if you run into someone who is NOT running the 6.1 version you'll have troubles.

Note also that your Outlook reference will have to be the "lowest common denominator" - so if you're running Outlook 2013, and you deploy to users running Outlook 2010, the reference will fail. If it's the other way around - you running 2010, and your users running 2013 - Access should be able to upsize it easily.
Avatar of gdunn59
gdunn59

ASKER

I already have the MS Outlook 15.0 Object Library.

When I try to add the Microsoft ActiveX Data Object 6.1 Library, I get the following error:

Name conflicts with existing module, project, or object library.

I've attached a file that shows what references I currently have selected.

Thanks,

gdunn59
C--Users-msc551-Desktop-References.PNG
with Microsoft ActiveX Data Object 2.1 Library are you getting the error?

if you do, remove the Microsoft ActiveX Data Object 2.1 Library and add the Microsoft ActiveX Data Object 6.1 Library
Avatar of gdunn59

ASKER

With the Microsoft ActiveX Data Object 2.1 library selected, I'm actually getting this error:

Error: 429
AssureUserPreReqs
ActiveX component can't create object
Avatar of gdunn59

ASKER

That's weird, if I get out of the database and then reopen it, I get the error:

Compile error:
User-defined type not defined.

Attached is another screen shot of what References I have selected now.

Thanks,

gdunn59
C--Users-msc551-Desktop-References2.PNG
Avatar of gdunn59

ASKER

Also, just curious, is there an easy way to determine which References are needed?

Thanks,

gdunn59
try doing a compact and repair, then DEBUG >Compile
You can determine which are needed like this:

1. Run a Debug - Compile, as Rey suggests
2. Open the References dialog and uncheck the reference you want to check. Be sure to write down the full path to that reference first.
3. Compile again

If your code compiles in Step 3, then you don't need that reference.

FWIW, you should not have the error you're getting with those references checked, Sounds like you may have troubles with your database. If you cannot fix it by other means, then create a new, blank database and import everything into that database. You'll have to re-make your references in the new database. And make a backup BEFORE you do this.
Avatar of gdunn59

ASKER

I've tried everything suggested, and I'm still getting the following error:

Error: 429
 AssureUserPreReqs
 ActiveX component can't create object

When I do a compile, it compiles with no errors, but if I click on a button that was designed by someone else that utilizes VBA Code, I get the above error.

Is there a way to get to the line of code where the error is quickly, without having to F8 through the entire thing?

Thanks,

gdunn59
<Is there a way to get to the line of code where the error is quickly, without having to F8 through the entire thing?>

comment the line in the code that says "On error ..."

this will give you an error msg. click on the debug button to take you to the erring line.
Avatar of gdunn59

ASKER

Ok, I commented out the line that says "On error . . . ", and finally was able to determine which line was causing the following error:

Error: 429
  AssureUserPreReqs
  ActiveX component can't create object


This is the line of code where the error is occurring:

Set doc = New AcroAVDoc 'hoping to get that rediculous error so i can catch it and change to something more specific

Not sure why.  Any clues?

Thanks,

gdunn59
"AcroAVDoc" is an adobe/acrobat item.
try adding the reference to the acrobat library.
Avatar of gdunn59

ASKER

I have the "Adobe Acrobat 10.0 Type Library" Reference selected already.  I also selected the "Acrobat Access 3.0 Type Library".

Not sure what else I would need.

Thanks,

gdunn59
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial