theschoolmaster
New member
- Local time
- Today, 23:37
- Joined
- Jan 1, 2022
- Messages
- 4
Hi. I have just joined the forum as I have a tricky (well, I think it's tricky) problem.
Before I delve into that, an introduction. I am a Chartered Electrical Engineer and retired Physics teacher. I live in East Sussex, England. I have used Access for many years, and consider myself fairly competent (although I still do very novice things like always turning to macros to automate things, rather than writing VBA modules (as will be confirmed by my problem shortly)! I think Access is a wonderful product (in contrast to Word, which is pants).
Now the problem.
I have a database which stores names and address details, including email address. I want to have a command button on the main form which when clicked will open the default email application (in my case Outlook) and pre-fill the 'To' email address and recipient's name, by picking these up from the currently open form. I tried a macro (!) using the EmailDatabaseObject command, but that won't accept field names in the relevant fields, only text literals.
So I Googled the problem and found a procedure, which I thought would work, and editted it for my particular use (the relevant fields on my form are: [address] and [label2], and the command button is Command1 ) :
Private Sub Command1_Click()
If Not IsNull(Me.address) Then
On Error GoTo cmd_send_email_Click_Err
Dim strTitle As String
Dim strEmailAddress As String
Dim strClientName As String
strEmailAddress = Me.address
strClientName = Me.label2
strTitle = "This is a message to “ & strClientName"
DoCmd.SendObject acSendNoObject, "", "", strEmailAddress, "", "", "strTitle", "", True, ""
cmd_send_email_Click_Exit:
Exit Sub
cmd_send_email_Click_Err:
If Err.Number = 2501 Then
MsgBox "The e mail hasn't been sent", _
vbInformation, "Sending to " & strClientName & " was cancelled"
Else
MsgBox Err.Description
End If
Resume cmd_send_email_Click_Exit
End If
MsgBox "You can't send an e mail to someone" & Chr(13) + Chr(10) & _
"without an e mail address ?", vbInformation, "ooops
"
End Sub
When it runs it generates the error "Object doesn't support this property or method".
What am I doing wrong? Is this in fact the wrong way to perform this action?
Any help will be very much appreciated.
Thank you!
Before I delve into that, an introduction. I am a Chartered Electrical Engineer and retired Physics teacher. I live in East Sussex, England. I have used Access for many years, and consider myself fairly competent (although I still do very novice things like always turning to macros to automate things, rather than writing VBA modules (as will be confirmed by my problem shortly)! I think Access is a wonderful product (in contrast to Word, which is pants).
Now the problem.
I have a database which stores names and address details, including email address. I want to have a command button on the main form which when clicked will open the default email application (in my case Outlook) and pre-fill the 'To' email address and recipient's name, by picking these up from the currently open form. I tried a macro (!) using the EmailDatabaseObject command, but that won't accept field names in the relevant fields, only text literals.
So I Googled the problem and found a procedure, which I thought would work, and editted it for my particular use (the relevant fields on my form are: [address] and [label2], and the command button is Command1 ) :
Private Sub Command1_Click()
If Not IsNull(Me.address) Then
On Error GoTo cmd_send_email_Click_Err
Dim strTitle As String
Dim strEmailAddress As String
Dim strClientName As String
strEmailAddress = Me.address
strClientName = Me.label2
strTitle = "This is a message to “ & strClientName"
DoCmd.SendObject acSendNoObject, "", "", strEmailAddress, "", "", "strTitle", "", True, ""
cmd_send_email_Click_Exit:
Exit Sub
cmd_send_email_Click_Err:
If Err.Number = 2501 Then
MsgBox "The e mail hasn't been sent", _
vbInformation, "Sending to " & strClientName & " was cancelled"
Else
MsgBox Err.Description
End If
Resume cmd_send_email_Click_Exit
End If
MsgBox "You can't send an e mail to someone" & Chr(13) + Chr(10) & _
"without an e mail address ?", vbInformation, "ooops

End Sub
When it runs it generates the error "Object doesn't support this property or method".
What am I doing wrong? Is this in fact the wrong way to perform this action?
Any help will be very much appreciated.
Thank you!