New to the Forum! (1 Viewer)

theschoolmaster

New member
Local time
Today, 05:08
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!
 

Jon

Access World Site Owner
Staff member
Local time
Today, 05:08
Joined
Sep 28, 1999
Messages
7,383
Welcome to the forums! We are the most active Microsoft Access community on the internet by far, with posts going back over 20 years!

To get started, I highly recommend you read the post below. It contains important information for all new users to this forum.

https://www.access-programmers.co.uk/forums/threads/new-member-read-me-first.223250/

We look forward to having you around here, learning stuff and having fun!
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 21:08
Joined
Aug 30, 2003
Messages
36,124
Labels don't have Value properties so you'd have to specify what you want, presumably the caption:

strClientName = Me.label2.Caption

You also don't want quotes around the variable in the SendObject line.

FYI I"m going to move this to a more appropriate forum since it contains a technical question.
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 00:08
Joined
Apr 27, 2015
Messages
6,321
I see your question is already in capable hands, so allow me ro welcome you to AWF!
 

theschoolmaster

New member
Local time
Today, 05:08
Joined
Jan 1, 2022
Messages
4
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!
Labels don't have Value properties so you'd have to specify what you want, presumably the caption:

strClientName = Me.label2.Caption

You also don't want quotes around the variable in the SendObject line.

FYI I"m going to move this to a more appropriate forum since it contains a technical question.
Thanks Paul. Done all that, and it has fixed the VBA error - but now it brings up a window asking me to set up an email account - presumably because it doesn't know Outlook is there and running?
BTW, which forum have you moved my query to? I'm getting a bit lost here....
 

jdraw

Super Moderator
Staff member
Local time
Today, 00:08
Joined
Jan 23, 2006
Messages
15,379
Welcome to AWF and Happy New Year, schoolmaster.
I see the New Year hasn't changed staff antics(y)
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 21:08
Joined
Aug 30, 2003
Messages
36,124
I moved this thread to the General forum, but you'll still see a redirect in the introductions forum.

So you can use Outlook to send/receive email? Is it shown as the default app for email in Default apps?
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 21:08
Joined
Aug 30, 2003
Messages
36,124
Looks like it was the default app issue:

 

theschoolmaster

New member
Local time
Today, 05:08
Joined
Jan 1, 2022
Messages
4
Thank you very much for your help Paul, much appreciated.
Happy New Year to you, and let's hope it's a better one than those we have become accustomed to.
David
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 21:08
Joined
Aug 30, 2003
Messages
36,124
Happy to help David!

I'd say we have nowhere to go but up, but... ;)
 

Users who are viewing this thread

Top Bottom