Results 1 to 3 of 3
  1. #1
    wattles is offline Novice
    Windows 11 Access 2016
    Join Date
    Nov 2023
    Posts
    3

    Object does not support this Property

    Hi there, being a newbie to Access VB I have stolen code from various sources......I think you'll be able to understand what I am trying to do but at the very end on the execution of the code I recieve a "Object does not support this Propertyd .....can anyone throw any light on why. I thought I had taken care of everything??? Perhaps not??



    Private Sub EmailTo_Click()


    On Error GoTo Err_EmailTo_Click

    Dim dbs As Database
    Dim rst As Recordset


    Dim stDocName As String
    Dim strSql As String
    Dim rs As Recordset

    Set dbs = CurrentDb()


    stDocName = Me!CboForms

    stSub = DLookup("[Subscription]", "[tblConfiguration]")

    strSql = "SELECT FarNorth.JPID, FarNorth.Title, FarNorth.FirstName, FarNorth.Surname, FarNorth.Email, SubID, Sub2.SubYear, Sub2.AmtInvoiced, Sub2.AmountPaid FROM FarNorth INNER JOIN Sub2 ON FarNorth.JPID = Sub2.SubID WHERE Sub2.AmtInvoiced and Sub2.SubYear = 2024 and Sub2.SubID = " & Me![JPID]

    'create recordset of JP's
    Set rst = CurrentDb.OpenRecordset(strSql, dbOpenSnapshot)

    If Me!CboForms = "Subscription Invoice" And rst![AmountPaid] = 40 Then 'Or Me!CboForms = "Subscription Reminder" Then ' Or Me!CboForms = "Subscription Reminder" And rst![AmountPaid] = 40 Then

    MsgBox rst![FirstName] & " " & rst![Surname] & " has paid the full subscription for the " & rst![SubYear] & " year! You will need to forward a Subscription Reminder notice!!"

    End If

    '+++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++

    ' ask the user if they would like to preview the invoice before sending

    Dim Msg, Style, Title, Help, Ctxt, Response, MyString
    Msg = "Do you want to preview the invoice before emailing for " & [Title] & " " & [Initials] & " " & [Surname] & "?"
    Style = vbYesNo + vbCritical + vbDefaultButton3
    Title = "Watchout!!!"
    Help = "DEMO.HLP"
    Ctxt = 1000
    Response = MsgBox(Msg, Style, Title, Help, Ctxt)

    If Response = vbYes Then ' User chose Yes.

    DoCmd.OpenReport stDocName, acViewPreview, , "FarNorth.JPID=" & Me!JPID, acWindowsNormal

    ElseIf Response = vbNo Then


    DoCmd.OpenReport stDocName, acViewPreview, , "FarNorth.JPID=" & Me!JPID, acHidden
    DoCmd.OutputTo acOutputReport, stDocName, acFormatPDF, CurrentProject.Path & "" & stDocName & ".pdf", True
    DoCmd.Close acReport, stDocName

    Dim oApp As New Outlook.Application
    Dim oEmail As Outlook.MailItem
    Dim fileName As String, todayDate As String


    'Export report in same folder as db with date stamp

    todayDate = Format(Date, "MMDDYYYY")

    fileName = Application.CurrentProject.Path & "" & stDocName_ & todayDate & ".pdf"

    DoCmd.OutputTo acReport, stDocName, acFormatPDF, fileName, False


    'Email the results of the report generated

    Set oEmail = oApp.CreateItem(olMailItem)

    With oEmail

    .Recipient = Me!Email
    .Subject = stDocName
    .Body = "Please find attached a " & stDocName
    .Attachments.Add fileName
    .Send

    End With

    DoCmd.Close acReport, stDocName, acSaveNo


    MsgBox "Email successfully sent!", vbInformation, "EMAIL STATUS"



    ' Log the invoice details

    ' Dim rs As DAO.Recordset
    Set rs = dbs.OpenRecordset("tblPrintedReports")

    rs.AddNew
    rs!PrintDate = Now()
    rs!Recipient = Me![FirstName] & " " & Me![Surname]
    rs!Document = stDocName
    rs.Update


    '+++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++
    Set rst = Nothing
    Set rs = Nothing


    MsgBox "The Subscription Invoice for " & rst![FirstName] & " " & rst![Surname] & " has been sent."


    Exit_EmailTo_Click:
    Exit Sub


    Err_EmailTo_Click:
    MsgBox Err.Description

    Resume Exit_EmailTo_Click
    End If


    End Sub

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    You're trying to reference dataset fields for a dataset that's closed.

    Set rst = Nothing
    MsgBox "The Subscription Invoice for " &
    rst![FirstName] & " " & rst![Surname] & " has been sent."



  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Please post more than one line of code within code tags.
    The # icon
    Code:
    Like this
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Object doesn't support property or method
    By Jamy in forum Programming
    Replies: 7
    Last Post: 07-15-2013, 01:42 AM
  2. object doesnt support this property or method
    By lexygirl in forum Access
    Replies: 1
    Last Post: 12-15-2011, 03:45 AM
  3. Replies: 6
    Last Post: 11-18-2011, 03:46 PM
  4. Object does not support this method or property
    By Vronsky in forum Programming
    Replies: 5
    Last Post: 05-30-2011, 02:09 PM
  5. Replies: 2
    Last Post: 02-28-2009, 03:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums