By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,128 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Appointments from Access 2K to Outlook 2K

P: n/a
I have an Access 2K DB that contains certain fields I want to pull into
an Outlook 2K task.

Here is my code:
--------------------------------------------------------
Function AddOutLookTask()
Dim appOutLook As Outlook.Application
Dim taskOutLook As Outlook.TaskItem
Set appOutLook = CreateObject("Outlook.Application")
Set taskOutLook = appOutLook.CreateItem(olTaskItem)
With taskOutLook
..Display
..Subject = "" ' I'd like to have my Client ID field here
..ReminderSet = False
..DueDate = "" ' I'd like to have my Next Contact Date field here
..Save
End With
End Function
--------------------------------------------------------

Here's the question (don't laugh ;)), what do I type so I can pull my
data from the DB? I placed the field names but kept getting this
error: Compile error: Variable not defined. I know I'm missing
somehting simple.

Thank you in advance for your help!

Nov 13 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Oh, if the form is open, you can refer to the fields like this:

..subject = me.txtSubject

I would put the code into a module outside the form and then pass
strSubject, lngClientID, etc to the function

Function AddOUtlookTask(byval strSubject as string, byval lngClientID
as Long...)

and then I could do this:

..Subject = strSubject
etc

The good thing about this is that your code is MUCH more modular and
you can use it elsewhere (export to another app)
PitchBlackSheep wrote:
I have an Access 2K DB that contains certain fields I want to pull into an Outlook 2K task.

Here is my code:
--------------------------------------------------------
Function AddOutLookTask()
Dim appOutLook As Outlook.Application
Dim taskOutLook As Outlook.TaskItem
Set appOutLook = CreateObject("Outlook.Application")
Set taskOutLook = appOutLook.CreateItem(olTaskItem)
With taskOutLook
.Display
.Subject = "" ' I'd like to have my Client ID field here
.ReminderSet = False
.DueDate = "" ' I'd like to have my Next Contact Date field here
.Save
End With
End Function
--------------------------------------------------------

Here's the question (don't laugh ;)), what do I type so I can pull my
data from the DB? I placed the field names but kept getting this
error: Compile error: Variable not defined. I know I'm missing
somehting simple.

Thank you in advance for your help!


Nov 13 '05 #2

P: n/a
Thank you so very much for your quick response!

I will give this a go. Just one more question, do I need to tell
access which database it needs to look at? Would it hurt to place
something like set db = CurrentDb or should I just leave it alone?
Cheers!!!

Nov 13 '05 #3

P: n/a
Here is the code now:

Function AddOutLookTask(ByVal strSubject As String)
Dim appOutLook As Outlook.Application
Dim taskOutLook As Outlook.TaskItem
Set appOutLook = CreateObject("Outlook.Application")
Set taskOutLook = appOutLook.CreateItem(olTaskItem)
With taskOutLook
..Display
..Subject = strSubject
..ReminderSet = False
..Save
End With
End Function

Get ready to laugh because I must have messed something up. I now get
a macro dialog box asking me to run or create one. What have I done
wrong? Thanks :)

Nov 13 '05 #4

P: n/a
No, you don't. Well, at least if you're just passing data from the
form's controls to Outlook. You don't because you don't need to go
anywhere else in the database hierarchy to get any other information.
(The form is already open, so it and its recordsource are already
available.)

so the function call could be something like this:

' Function AddOUtlookTask(byval strSubject as string, byval lngClientID
as Long...)

AddOutlookTask("Meeting with Joe", 15, ...)
no need to reference anything else.

Nov 13 '05 #5

P: n/a
Thank you for your help. When I entered in AddOUtlookTask(byval
strSubject as string, byval lngClientID asLong), Access kept asking me
to run a Macro so I changed my code just a bit more:

Option Explicit
Function AddOutLookTask()
Dim appOutLook As Outlook.Application
Dim taskOutLook As Outlook.TaskItem
Dim EscrowNo As Long
Dim NextContact As Date
Set appOutLook = CreateObject("Outlook.Application")
Set taskOutLook = appOutLook.CreateItem(olTaskItem)
With taskOutLook
..Display
..Subject = EscrowNo ' The Escrow Numbers are typed in, not
autonumbered
..ReminderSet = False
..DueDate = NextContact ' I have the date in the table as
1/15/05
..Save
End With
End Function

Outlook runs but all I get is a zero in the subject field and 12/1/99
in the date field. My form is open and the current record is active.
I'm ready to give up. Any last suggestions? Thanks :)

Nov 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.