473,469 Members | 1,447 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do I fix Compile Error: User-defined type not defined?

4 New Member
I am new to the forum and new to Access, so please be simple and descriptive if possible. I am having a problem with a button on a form that saves, opens a report in pdf, and emails the report to the client. I believe the email is what is failing. I get the Error message "Compile Error: User-defined type not defined" and this is the section of code that pops up:

Expand|Select|Wrap|Line Numbers
  1. Public Function SendClientEmail(emailto As Variant, attachmentpath As Variant, subjectmsg As String, msg As String, Optional attachmentpath2 As Variant)
  2. On Error GoTo SendClientEmail_Err
  3.     Dim appOutLook As Outlook.Application
  4.     Dim MailOutLook As Outlook.MailItem
  5.     Set appOutLook = CreateObject("Outlook.Application")
  6.     Set MailOutLook = appOutLook.CreateItem(olMailItem)
The "Dim appOutLook As Outlook.Application" portion is highlighted in blue

and highlighted in yellow is the first line "Public Function SendClientEmail(emailto As Variant, attachmentpath As Variant, subjectmsg As String, msg As String, Optional attachmentpath2 As Variant)"

Can anyone walk me through how to fix this error? I appreciate any help I can get.
Aug 4 '10 #1
6 19893
MikeTheBike
639 Recognized Expert Contributor
Hi

If you want to use late binding (as you are if you are using CreatObject()) then you should dimension the variable like this
Expand|Select|Wrap|Line Numbers
  1. Dim appOutLook As Object
  2. Dim MailOutLook As Object
If you want to use early binding then you need to set a reference to the Microsoft Outlook 11.0 Object Library (Tools->References when in a VBA Module). This, I believe, is why you are getting the error.
ie. code like this
Expand|Select|Wrap|Line Numbers
  1.     Dim appOutLook As Outlook.Application
  2.     Dim MailOutLook As Outlook.MailItem
  3.  
  4.     Set appOutLook = New Outlook.Application
  5.     Set MailOutLook = New Outlook.MialIten
HTH

But don't ask me how to use these object because I never have (not yet anyway!)

MTB
Aug 6 '10 #2
NeoPa
32,556 Recognized Expert Moderator MVP
Any code using objects from another application (in this case Outlook) must ensure that the relevant libraries are referenced otherwise the compiler will not understand the context and give you the error you got.

I think Application Automation gives you what you need for this. If there is anything missing let me know.

BTW, Mike was essentially right in what he was saying too.

Welcome to Bytes!
Aug 6 '10 #3
travjbad1
4 New Member
Thanks for the help. Just in case someone else has the same problem here is another way to solve it. Open up Microsoft Visual Basic > open Tools > References. Then just make sure the program you were trying to use, in this case Outlook is checked. In my case someone got into the Visual Basic and accidentally unchecked it. Thanks for the help everyone.
Aug 10 '10 #4
NeoPa
32,556 Recognized Expert Moderator MVP
That's not so much another way of doing it, as a repetition of what was said in both of the previous posts. Would it be fair to say you didn't understand what was being said?
Aug 10 '10 #5
travjbad1
4 New Member
Whoops! I didn't read very carefully. You're right. I got help last week before someone had time to post something here and I thought I'd just come in and say thanks. I'm new so I thought I'd provide something in simple terms that someone like me could understand. Like I said thank you for the help though.
Aug 10 '10 #6
NeoPa
32,556 Recognized Expert Moderator MVP
That's fine :)

Actually, it does help sometimes for things to be stated in simpler English (which is why I was worried you hadn't understood). I suspect there are occasions when we give perfect answers, except in the respect that some people find them hard to understand. We live and learn.
Aug 10 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Danny Boelens | last post by:
Hi all, today I ran into a compile error after a compiler upgrade. I made a small example to demonstrate my compile error: template<typename T1, typename T2> class A {}; class B
1
by: Tony Johansson | last post by:
Hello! I get compile error when compiling using the command javac from the command terminal window(CMD). I have just two classes which are called HelloWorld.java and Slask.java. I have both...
0
by: Tony Johansson | last post by:
Hello! I get compile error when compiling using the command javac from the command terminal window(CMD). I have just two classes which are called HelloWorld.java and Slask.java. I have both...
2
by: Tony Johansson | last post by:
Hello! I get compile error when compiling using the command javac from the command terminal window(CMD). I have just two classes which are called HelloWorld.java and Slask.java. I have both...
7
by: Ook | last post by:
What am I doing wrong? This code gives a compile error: 'SortedList<T>::insert' : illegal call of non-static member function. I've tried several variations of this, but keep getting the same error....
10
by: Chris LaJoie | last post by:
Our company has been developing a program in C# for some time now, and we haven't had any problems with it, but just last night something cropped up that has me, and everyone else, stumped. I...
0
by: Jim Heavey | last post by:
Internal Compiler Error: stage 'BEGIN' Hello, I had an application which was working just fine and I decided to modify all database access within the application to utilizie a new Namespace that I...
5
by: MLH | last post by:
A97 aborts creation of MDE reporting that there's a compile error in one form. Sure enough, if I remove the form from the source database and attempt to compile the MDE, it succeeds. But when I...
2
Schwack
by: Schwack | last post by:
I've just started learning C++ (got bored at work) and I'm using VC++ to compile some simple code but I get a compile error in test.cpp when using "getline". I've searched the internet and this...
17
by: MLH | last post by:
I have tested the following in immed window: ?isnumeric(1) True ?isnumeric(1.) True ?isnumeric(1.2) True ?isnumeric(1.2.2)
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.