email problem

Splity

Registered User.
Local time
Today, 20:45
Joined
May 8, 2001
Messages
16
Hi,
I have created a databse in which a user enters their name along with other data.Once the data is entered the database manager can access any record and add a required action to the entered data.The manager then needs to send an email to inform the person who entered the data to of the action.I am trying to use a command button to do the following:-

On the click of the command button the code looks to see if 2 of a possible 4 tickboxs have been ticked.If they are not then the user is prompted to do this.Next the code takes the name of the user from a field and uses the name for the email recipient.
The problem is that if the user types their name in correctly the email is sent and everything works fine, but if they type in an invalid name then I want the program to prompt them of an invalid name. At the moment the code crashes if an invalid name is used and closes MSAccess down.

Sub MailMessage_Click()

On Error GoTo NoName
Dim Msg, Msg2, Msg3
Dim Name As String

If Form_Main.TickBox1 = True And Form_Main.TickBox2 = True Or Form_Main.TickBox1 = True And Form_Main.TickBox3 = True Or Form_Main.TickBox1 = True And Form_Main.TickBox4 = True Then

Name = Form_Main.Issued_By
DoCmd.SendObject acSendNoObject, , , Name, , , "Mail Title", "Mail Message", 0
Msg3 = MsgBox("Notification has been sent", vbOKOnly, "Message")
Else
Msg = MsgBox("Agreement is required by 2 Parties", vbOKOnly, "Message")

Exit Sub
End If

Exit_NoName:
Exit Sub

NoName:
Msg2 = MsgBox("Invalid or No Name In Issued By Field", vbOKOnly, "Message")
Resume Exit_NoName

If I put- If Name = Error Then
Resume NoName
End If
Before the DoCmd line then the invalid part of the code works fine but it now crashes when the correct name is entered.
I need to try and put the 2 together
I would be grateful for any help...Thanks in advance.
 
Hi Splity

This may be a bit of a simplistic answer but have you though of having the email recipient names in a pull down list with it's limit to list property set to no. Then the user can only pick a name from the list and it will always be correct.

HTH

Helena
 
Thanks for your reply Helana.
I have sorted the problem now and I have included your suggestion of the drop down box.
 

Users who are viewing this thread

Back
Top Bottom