VBA Code to Differentiate New Data from Old Data (1 Viewer)

axkoam

New member
Local time
Today, 10:12
Joined
Jun 19, 2012
Messages
7
Windows 7, Microsoft Access 2007, VBA

I have a routine I've put together where I send out a bunch of records to the email address that's in one of the fields in each record. Some records don't have emails yet (null field) so I made a form for a user to enter the email into that field.

These records are orders, and when they come in, I'd like to immediately email the records that do have an email and then once the user enters the email addresses for the others, send them out too.

As of now, I can't figure out how to only send out the records with newly recorded email addresses. Right now my script would send the records that had email addresses in the first place out twice (once initially, and then again once the user enters in the null emails and clicks send).

What would be an approach to just having the records that haven't been sent yet, get sent?
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 10:12
Joined
Aug 30, 2003
Messages
36,127
As posted elsewhere:

One way would be a yes/no field in the table, for example "EmailSent". Set it to True when you send an email, and exclude those with True in your routine.
 

axkoam

New member
Local time
Today, 10:12
Joined
Jun 19, 2012
Messages
7
Thanks, should have thought of that.
 

axkoam

New member
Local time
Today, 10:12
Joined
Jun 19, 2012
Messages
7
Thanks, problem solved.
I used a SQL update statement to set the value of the yes/no field, for anyone following.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 10:12
Joined
Aug 30, 2003
Messages
36,127
No problem.
 

Users who are viewing this thread

Top Bottom