Compile Error

jonamua1971

Registered User.
Local time
Today, 13:39
Joined
Mar 3, 2007
Messages
97
Hi all,
below is my codes i have used ,but i keep getting the same error.
please note my database is split.
Any help will be appreciated.
The database works just fine when it is not split.
rivate Sub cmdAddAppt_Click()
On Error GoTo AddAppt_Err
' Save record first to be sure required fields are filled.
DoCmd.RunCommand acCmdSaveRecord
' Exit the procedure if appointment has been added to Outlook.
If Me!AddedToOutlook = True Then
MsgBox "This appointment already added to Microsoft Outlook"
Exit Sub
' Add a new appointment.
Else

Dim objAppt As Object
Dim outappt As Outlook.AppointmentItem
Set outobj = GetObject("", "outlook.application")
Set outappt = outobj.CreateItem(olAppointmentItem)
With outappt
.Start = Me!ApptDate & " " & Me!ApptTime

.Subject = Me!Appt
If Not IsNull(Me!ApptNotes) Then .Body = Me!ApptNotes
If Not IsNull(Me!ApptLocation) Then .Location = _
Me!ApptLocation
If Me!ApptReminder Then
.ReminderMinutesBeforeStart = Me!ReminderMinutes
.ReminderSet = True
End If
.Save
End With
End If
' Release the Outlook object variable.
Set outobj = Nothing
' Set the AddedToOutlook flag, save the record, display a message.
Me!AddedToOutlook = True
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Appointment Added!"
Exit Sub
AddAppt_Err:
MsgBox "Error " & Err.Numbe
End Sub
 
Two things:

1. It would be helpful to have you tell use the actual error you are getting and which line is highlighted.

2. use the code tags when posting here to make the code more easily read. put the word code in square brackets at the beginning of the code and the word /code in square brackets at the end.

I just spotted something that may be your problem here:
Code:
AddAppt_Err:
MsgBox "Error " & Err.Numbe
End Sub
missing the R in Number
 
This is not the kind of question I would normally answer. But you haven't told us anything. What do you mean you keep getting the same error? Are we allowed to know what/where the error is?

I assume that the lack of "P" in the word Private has more to do with a cut/paste problem?

More info!
 
Compile Error

Thank you very much for youe response.
Here is the message am getting:Msg
Msg" Compile error:
User-defined type not defined

Highlighted code:
Dim outapp As Outlook Appointment item

Thats what am getting when i try to add an appointment to outlook.
thanks
 
Have you set a reference to Microsoft Outlook? (Tools > References in the VBA window)
 
Thanks Bob!
i have done that too! i keep getting the same error msg.
when put the database togehter without splitting the tables and the rest.the appointments are sent to outlook calendar without any problems.
But when i link the tables that when i start getting the msg : compile error user- defined type not defined.
Dim Outapp As outlook Appointment item
Thanks
 

Users who are viewing this thread

Back
Top Bottom