Getting email address from form field for macro (2 Viewers)

pbutler

New member
Local time
Today, 02:46
Joined
Aug 27, 2012
Messages
15
Hi,

I am trying to send an individualised report pdf to a number of people in my organisation using a macro. It is all working well and I have got a working loop that selects each individual one at a time and sends the email with the pdf attachment. The To field in the macro is set to retrieve the email address from a field in an open form [Forms]![frmAttendance]!.
I have used this in the past with no problem, but now Access says they could not identify the recipient and stops the macro. If I enter the To line manually then it sends the email correctly (but with 500+ emails to send this is not an option).
The email field in the underlying table is set to Short Text.
Any thoughts?

Many thanks,
Pino
 

Ranman256

Well-known member
Local time
Yesterday, 21:46
Joined
Apr 9, 2015
Messages
3,807
What do you mean,"could not identify"?
Is the field blank?
Is it an invalid email?
 

pbutler

New member
Local time
Today, 02:46
Joined
Aug 27, 2012
Messages
15
What do you mean,"could not identify"?
Is the field blank?
Is it an invalid email?
The field is not blank and the email is not invalid, but Access does not seem to be able to recognise it. That is the message it gives me.
 

pbutler

New member
Local time
Today, 02:46
Joined
Aug 27, 2012
Messages
15
This is the macro and the message I get:

Macro.PNG
Message.PNG
 

Gasman

Enthusiastic Amateur
Local time
Today, 02:46
Joined
Sep 21, 2011
Messages
7,898
How do you identify what email it is?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:46
Joined
Oct 29, 2018
Messages
14,560
Hi. Can you also post a screenshot of the email header showing the To address. We just want to see what the macro is getting from the open form.

In other words, do you see the same email address between the email and the form?
 

pbutler

New member
Local time
Today, 02:46
Joined
Aug 27, 2012
Messages
15
Hi. Can you also post a screenshot of the email header showing the To address. We just want to see what the macro is getting from the open form.

In other words, do you see the same email address between the email and the form?
Hi,

Good call. I had it set to not edit the email, so I had not seen it. It is not retrieving the email address from the open form field, just entering what I thought was a parameter. Screenshots of the form that selects the person and provides the email address, and of the actual email with the To line (which is obviously wrong).

Form.PNG
email.PNG
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:46
Joined
Oct 29, 2018
Messages
14,560
Hi. Thanks for posting the screenshots. I see the problem now. In you macro, add an equal sign before the Forms!... reference in the To argument. ie.

=Forms!...

Hope that helps...
 

pbutler

New member
Local time
Today, 02:46
Joined
Aug 27, 2012
Messages
15
Hi. Thanks for posting the screenshots. I see the problem now. In you macro, add an equal sign before the Forms!... reference in the To argument. ie.

=Forms!...

Hope that helps...
Hi,

Thanks for the suggestion. Unfortunately that also throws an error, please see below:
1607439531052.png
 

Gasman

Enthusiastic Amateur
Local time
Today, 02:46
Joined
Sep 21, 2011
Messages
7,898
PMFJI,
Works for me as well?, even if 2007. Try a hardcoded email address?
1607443362070.png
 

pbutler

New member
Local time
Today, 02:46
Joined
Aug 27, 2012
Messages
15
Working now. The form was opening with no records in it, not sure why!
Thanks all so much for your help.

Pino
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:46
Joined
Oct 29, 2018
Messages
14,560
Working now. The form was opening with no records in it, not sure why!
Thanks all so much for your help.

Pino
Hi. Congratulations! Glad to hear you got it to work. Good luck with your project.
 

Isaac

Lifelong Learner
Local time
Yesterday, 18:46
Joined
Mar 14, 2017
Messages
4,339
Hi,

I am trying to send an individualised report pdf to a number of people in my organisation using a macro. It is all working well and I have got a working loop that selects each individual one at a time and sends the email with the pdf attachment. The To field in the macro is set to retrieve the email address from a field in an open form [Forms]![frmAttendance]!.
I have used this in the past with no problem, but now Access says they could not identify the recipient and stops the macro. If I enter the To line manually then it sends the email correctly (but with 500+ emails to send this is not an option).
The email field in the underlying table is set to Short Text.
Any thoughts?

Many thanks,
Pino
is it a matter of auto name checking or something?
 

Users who are viewing this thread

Top Bottom