Text box contains

Dear Experts

I have an Access 2010 database I use to manage subscriptions to a newsletter.  

I'm using the code below to unsubscribe people.  But one or two people get missed because they were originally subscribed under a different email address (for example joebloggs@googlemail.com vs joebloggs@gmail.com).

So I need to be able to put in a quick check in the code to see if that email address is actually in the table, if the email address can be found then I need a message box to pop up.

Private Sub Remove_Click()

' ********* Check Bit  *********
If Len(Me!RemoveEmail & "") = 0 Then
       MsgBox "Please enter the email address of the person you wish to remove", vbExclamation, "Warning !"
        Cancel = True
        Exit Sub
    End If
    
    

' ********* Confirm Bit  *********

If MsgBox("Are you sure you wish to remove " & Me!RemoveEmail & " ?", vbQuestion + vbYesNo, "Warning !") = vbNo Then
Me.RemoveEmail = ""
Exit Sub

Else

' ********* Remove Bit  *********

Dim StrRemove As String
StrRemove = "'" & Me.RemoveEmail & "'"
CurrentProject.Connection.Execute "UPDATE [WeeklyMembers] SET [WeeklyMembers].[Removed] = -1 WHERE [WeeklyMembers].[Email] = " & StrRemove
CurrentProject.Connection.Execute "UPDATE [WeeklyMembers] SET [WeeklyMembers].[Unsubscribed Date] = #" & Now() & "# WHERE [WeeklyMembers].[Email] = " & StrRemove
MsgBox (Me.RemoveEmail & " has been removed"), , "Removed"
Me.RemoveEmail = ""
End If
End Sub

Open in new window


Can anybody help
correlateAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:

if dcount("*","WeeklyMembers","Email='" & Me.RemoveEmail & "'")>0 then
  msgbox "Email exists"
  else
  msgbox "Email IS NOT in table"

end if
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
correlateAuthor Commented:
Perfect - thank you very much
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.