I have been tasked to create a 'simple' form in Access providing managers to input necessary changes. I have 2 command buttons on the form and a check box. Command button 1 updates my table for multiple entries, and command button 2 e-mails the table in HTML format to my team, appends the data entered to a back-up table, and deletes the entries on the current table.
When the check box on my form is checked (indicating a permanent change) I need command button 2 to run the same events, but also CC another distribution list and reword the email message. I have been looking all over the Internet for help and enlisted the help from other departments with no avail. This was supposed to be a simple form, but after feedback from other users it turned into something way beyond my knowledge of VB. I converted all my macros to VB, and am learning tons about writing code. However I am turning to you all for you assistance. Please help!!!
If chkPerm = True Then
docmd....
If chkPerm = False Then
docmd....
Below is the ACTUAL 'Event Procedure' code for Command button 2 that I thought would work, but after testing realized it didnt... It is a long code for 1 command button, but due to procedures and error handlers I didnt know any other way to write it...
When the check box on my form is checked (indicating a permanent change) I need command button 2 to run the same events, but also CC another distribution list and reword the email message. I have been looking all over the Internet for help and enlisted the help from other departments with no avail. This was supposed to be a simple form, but after feedback from other users it turned into something way beyond my knowledge of VB. I converted all my macros to VB, and am learning tons about writing code. However I am turning to you all for you assistance. Please help!!!
If chkPerm = True Then
docmd....
If chkPerm = False Then
docmd....
Below is the ACTUAL 'Event Procedure' code for Command button 2 that I thought would work, but after testing realized it didnt... It is a long code for 1 command button, but due to procedures and error handlers I didnt know any other way to write it...
Code:
Private Sub Notify_Click() On Error GoTo Err_handler Perm = chkbox If chkPerm = False Then DoCmd.SendObject acTable, "Skills", "HTML(*.html)", "SMTP:CMTDialerTeam@ROOT", "", "", "Skill Change Request", "Please update this associates skills. ", False, "" DoCmd.SetWarnings False DoCmd.GoToRecord acForm, "Skill Change Request Form", acNewRec Beep MsgBox "Your e-mail was sent. You will be notified upon completion.", vbOKOnly, "Successful" DoCmd.RunMacro "Make Back-Up", , "" If iResponse = vbOKOnly Then DoCmd.Quit DoCmd.SetWarnings True Else End If End If If chkPerm = True Then DoCmd.SendObject acTable, "Skills", "HTML(*.html)", "SMTP:CMTDialerTeam@ROOT", "CMT_ResourceDesk@oomc.com", "", "Skill Change Request", "Please update this associates skills. CMT_ResourceDesk, pleae update the Voice List and Associate Database. ", False, "" DoCmd.SetWarnings False DoCmd.GoToRecord acForm, "Skill Change Request Form", acNewRec Beep MsgBox "Your e-mail was sent. You will be notified upon completion.", vbOKOnly, "Successful" DoCmd.RunMacro "Make Back-Up", , "" If iResponse = vbOKOnly Then DoCmd.Quit DoCmd.SetWarnings True End If End If 'error handler Err_handler: If Err.Number = 2293 Then iResponse2 = MsgBox("Skill Changes were not sent to the CMT Dialer Team. Do you want to try to send again?", vbYesNo, "E-Mail Not Sent") 'MsgBox "Skill change request not sent" If iResponse2 = vbNo Then Beep MsgBox "Your changes were not saved, and Database will close automatically.", vbOKOnly, "Unsuccessful" DoCmd.Quit End If If iResponse2 = vbYes Then If chkPerm = False Then DoCmd.SendObject acTable, "Skills", "HTML(*.html)", "SMTP:CMTDialerTeam@ROOT", "", "", "Skill Change Request", "Please update this associates skills. ", False, "" DoCmd.SetWarnings False DoCmd.GoToRecord acForm, "Skill Change Request Form", acNewRec Beep MsgBox "Your e-mail was sent. You will be notified upon completion.", vbOKOnly, "Successful" DoCmd.RunMacro "Make Back-Up", , "" If iResponse = vbOKOnly Then DoCmd.Quit DoCmd.SetWarnings True Else End If End If If chkPerm = True Then DoCmd.SendObject acTable, "Skills", "HTML(*.html)", "SMTP:CMTDialerTeam@ROOT", "CMT_ResourceDesk@oomc.com", "", "Skill Change Request", "Please update this associates skills. CMT_ResourceDesk, pleae update the Voice List and Associate Database. ", False, "" DoCmd.SetWarnings False DoCmd.GoToRecord acForm, "Skill Change Request Form", acNewRec Beep MsgBox "Your e-mail was sent. You will be notified upon completion.", vbOKOnly, "Successful" DoCmd.RunMacro "Make Back-Up", , "" If iResponse = vbOKOnly Then DoCmd.Quit DoCmd.SetWarnings True End If End If Beep MsgBox "Your e-mail was sent. You will be notified upon completion.", vbOKOnly, "Successful" Else DoCmd.Quit End If End If End Sub
Comment