+ Reply to Thread
Results 1 to 2 of 2

The VBA code doesnt seem to pick up the data from the form

Hybrid View

steveallany2k6 The VBA code doesnt seem to... 10-16-2012, 08:32 AM
steveallany2k6 Re: The VBA code doesnt seem... 10-16-2012, 09:05 AM
  1. #1
    Registered User
    Join Date
    07-09-2012
    Location
    UK
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    35

    The VBA code doesnt seem to pick up the data from the form

    I have a form which i want to use to create appointments in Outlook. I have the VBA code to do this but for some reason the code doesnt pick up the data from the form any suggestions what i have done wrong?

    this is the code i am using

    Sub CreateAppointment1()
             Dim dtDue As String
             Dim tmDue As String
             dtDue = DueDate
             tmDue = DueTime
             
             
             
             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 AddedToOutlook = True Then
                MsgBox "This Case is already in Monitoring Mode"
                Exit Sub
             ' Add a new appointment.
             Else
                Dim outobj As Outlook.Application
                Dim outappt As Outlook.AppointmentItem
                Dim APPDue As String
                APPDue = dtDue & " " & tmDue & ":00"
                
                Set outobj = CreateObject("Outlook.Application")
                Set outappt = outobj.CreateItem(olAppointmentItem)
                
                With outappt
                
                   .Start = Now() + 1
                  ''''''''''''''''''APPDue
                   .Duration = "5"
                   .Subject = "Monitoring someone at " & Site
                   If Not IsNull(Descriptions) Then .Body = Description
                   If Not IsNull(Site) Then .Location = Site
                   
                
                   .Save
                End With
             End If
             ' Release the Outlook object variable.
             Set outobj = Nothing
             ' Set the AddedToOutlook flag, save the record, display a message.
             AddedToOutlook = True
             DoCmd.RunCommand acCmdSaveRecord
             MsgBox "Appointment Added!"
          Exit Sub
    AddAppt_Err:
             MsgBox "Error " & Err.Number & vbCrLf & Err.Description
             Exit Sub
          End Sub
    Last edited by steveallany2k6; 10-16-2012 at 08:36 AM. Reason: add code

  2. #2
    Registered User
    Join Date
    07-09-2012
    Location
    UK
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    35

    Re: The VBA code doesnt seem to pick up the data from the form

    Ive solved the problem, im thick. i had placed the code in a module and called it from the click button, when i have changed it as it is part of the click procedure its worked

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1