Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to add a second command to a click button 3

Status
Not open for further replies.

officemanager2

Technical User
Oct 11, 2007
116
CA
I hope this is clear. Currently I have a database (built with help from this board) that can keep a timestamped note attached to a specific person. I've been able to find/modify some code so when I am on the record of a specific person I can click a button and an email will load.

What I can't figure out is how to get a timestamped note to appear once the email is sent. I'd be happy if the note form opened and a note could be manually put in, which is how the current note function works, or simply have a record appear in the notes section that the email was sent.

I've been trying to put the code between the Exit Sub and End Sub lines but nothing is working and perhaps I need to create a new sub command that links into the sub command to create the email?
 
Where in your (unknown) code are you stuck ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hard to tell without seeing any of your code, but this:
I've been trying to put the code between the Exit Sub and End Sub lines
suggests to me that you may try adding your code before the Exit Sub statement.

Sometimes the error handling code is between the Exit Sub and End Sub and during normal operation the process stops at the Exit Sub statement.
 
The code to launch the email is

Private Sub sendemail_Click()
On Error GoTo Err_Command57_Click

Dim stDocName As String

stDocName = "Empty_Report"

DoCmd.SendObject acSendNoObject, stDocName, acFormatXLS, Me.EmailAddress, , , "Update", , True

Exit_Command57_Click:
Exit Sub


Err_Command57_Click:
MsgBox Err.Description
Resume Exit_Command57_Click
End Sub

I've tried putting

DoCmd.OpenForm "frmAddNote"

between the exit sub and end sub but there is no result from this.

 
Why not simply this ?
Code:
Private Sub sendemail_Click()
DoCmd.SendObject acSendNoObject, "Empty_Report", acFormatXLS, Me!EmailAddress, , , "Update", , True
DoCmd.OpenForm "frmAddNote"
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
That works great!! Thanks

Much easier than what I had. Do you have any advice for mass emails? Meaning sometimes I speak with one person at a time, but other times it would be best to send to everyone with one click and have all records updated that they have received the emails.

Thanks again, I'm still working through Access desktop developers guide ... it's a slow read.
 
Thanks again, I'm still working through Access desktop developers guide ... it's a slow read.
And a good cure for insomnia! : )
 
LOL ... helps one sleep, gives you a work out just by holding the thing up to read it when on public transport ... that book does it all!
 

I don't think you need "Exit_Command57_Click:" in your code, it does not do anything
[tt]
Private Sub sendemail_Click()
On Error GoTo Err_Command57_Click
Dim stDocName As String

stDocName = "Empty_Report"

DoCmd.SendObject acSendNoObject, stDocName, acFormatXLS, Me.EmailAddress, , , "Update", , True

Exit_Command57_Click:
Exit Sub

Err_Command57_Click:
MsgBox Err.Description
Resume Exit_Command57_Click
End Sub

[/tt]

Have fun.

---- Andy
 
I would typically leave the Resume and Exit...: lines in the code. It provides one exit door and allows you to have code to clean up your environment such as setting object variable to nothing, closing recordsets, etc.

In the above code it doesn't add much of any value but it would keep your code consistent.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top