Oct 02 2024 06:19 AM - edited Oct 02 2024 06:21 AM
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
Oct 02 2024 06:54 AM - edited Oct 02 2024 07:16 AM
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
Oct 02 2024 07:14 AM
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
Oct 02 2024 07:22 AM
Hi,
The property sheet shows that the text box + field name contain a space. Therefore you have to put it in square brackets in VBA: Me.[Project Name].Value
Servus
Karl
****************
Access Forever News DevCon
Access-Entwickler-Konferenz AEK - 19./20.10. Nürnberg
Oct 02 2024 07:33 AM
@Karl_Donaubauer Thank you, I seem to still have something wrong, I added the square brackets and I get the following:
Oct 02 2024 12:56 PM
Oct 02 2024 12:59 PM
Oct 02 2024 01:33 PM
Oct 02 2024 02:40 PM
Oct 02 2024 02:48 PM
Oct 02 2024 03:12 PM
Here is what the control box is called for the project name:
Here is the code with the error message
Im sure it is something really basic im missing and just not seeing or finding it. I appreciate all your advice so far
Oct 02 2024 03:38 PM
Thank you. I think this was mentioned in a previous response.
Your code reference is Project_Name with an underscore, which is not the same as [Project Name].
Try replacing Project_Name in the code with [Project Name]
Also, a reminder. This kind of fiddly name stuff is why most professional and experienced Access developers do not use object names with spaces in them. It gets slippery when trying to track down errors like this.
Oct 02 2024 05:34 PM
Thank you for the advice and note about the object names with spaces, i will for sure keep that in mind moving forward. I tried your suggestion with replacing it with [Project Name] and I now get a Runtime Error code