Forum Discussion

kevin675's avatar
kevin675
Copper Contributor
Oct 02, 2024

COMPILE ERROR (MS-Access)

Hello All,

 

I am fairly new to programming our MS-Access Database, i have built a tool/button to allow my users to click and it opens a new email from their outlook.  I am trying to get a very specific subject line to carry over our project number & what we call out project label/name.  I keep getting this "Compile Error: Method or data member not found" and can not seem to figure out what i have wrong in the code or why it wont find the project label that is in the database. Im sure this is something simple i am just missing

 

12 Replies

  • Hi,

     

    There are some ambiguities in your description. You write

    > the project label that is in the database

     

    1. What is "CurrentProjectName"? A field name or a control name or both? If a control, then which kind of control? A label control wouldn't have a "Value" property.


    2. "in the database" is not enough. Since you are referencing it with Me, it must be in the same object (or its data source) as the code. If that's the case then:

    In which kind of Access object are "CurrentProjectName" and the code? A form or a report?

     

    Depending on your answers to all these questions, it could help to use Me! instead of Me.

     

    Servus
    Karl
    ****************

    Access Forever News DevCon
    Access-Entwickler-Konferenz AEK - 19./20.10. Nürnberg

    • kevin675's avatar
      kevin675
      Copper Contributor

      Karl_Donaubauer 

       

      Thank you for your reply, i am trying to pull the data from this field:


      For Some reason, it works on another button we have which is where i snagged the code from, but when i add that same code to the new button is when im getting the COMPILE ERROR

       

      This Button pulls the data im needing without an issue

      using this code, it works fine for the button above but not the new button i created

      Private Sub cmdCopytoEmail_Click()
      Dim ol As New Outlook.Application
      Dim MI As MailItem
      Set MI = ol.CreateItem(olMailItem)
      MI.Subject = "Proj #" & Me.ID.Value & "-" & Me.Project_Name.Value
      MI.BodyFormat = olFormatHTML
      MI.Display
      Set MI = Nothing
      Set ol = Nothing
      End Sub

       

Resources