Code:
Private Sub SubmitButton_Click()
Dim stDocName As String
stDocName = "Report_Charter_Redesign"
' Saves the data inputted on the form and opens up a report with the data that was entered.
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport stDocName, acViewReport, , "[Charter_ID] = " & [Charter_ID]
Dim strSQL As String
strSQL = "INSERT INTO Table_Charter_Form_Redesign (Customer_Name, Event_Type, People_Num, Pickup_Address, Destination_Address, Special_Notes, Order_Date, Event_Date, Special_Needs, Branch, Pickup_Time, Departure_Time, Quote, Customer_Phone, Payment_Method, Manager_Name, Manager_Contact, Driver, Branch_Details, Paid_Full, Paid_Date, Vehicles_Assigned) " & _
"SELECT [Forms]![Form_Charter_Redesign]![CustomerNameBox] AS Expr1, " & _
"[Forms]![Form_Charter_Redesign]![EventBox] AS Expr2, " & _
"[Forms]![Form_Charter_Redesign]![NumberPeopleBox] AS Expr3, " & _
"[Forms]![Form_Charter_Redesign]![PickupAddressBox] AS Expr4, " & _
"[Forms]![Form_Charter_Redesign]![DestinationAddressBox] AS Expr5, " & _
"[Forms]![Form_Charter_Redesign]![NotesBox] AS Expr6, " & _
"[Forms]![Form_Charter_Redesign]![OrderDateBox] AS Expr7, " & _
"[Forms]![Form_Charter_Redesign]![EventDateBox] AS Expr8, " & _
"[Forms]![Form_Charter_Redesign]![SpecialNeedsBox] AS Expr9, " & _
"[Forms]![Form_Charter_Redesign]![ComboBranch] AS Expr10, " & _
"[Forms]![Form_Charter_Redesign]![PickupTimeBox] AS Expr11, " & _
"[Forms]![Form_Charter_Redesign]![DepartureTimeBox] AS Expr12, " & _
"[Forms]![Form_Charter_Redesign]![QuoteBox] AS Expr13, " & _
"[Forms]![Form_Charter_Redesign]![CustomerPhoneNumberBox] AS Expr14, " & _
"[Forms]![Form_Charter_Redesign]![PaymentMethodBox] AS Expr15, " & _
"[Forms]![Form_Charter_Redesign]![BranchManagerBox] AS Expr16, " & _
"[Forms]![Form_Charter_Redesign]![ManagerNumberBox] AS Expr17, " & _
"[Forms]![Form_Charter_Redesign]![DriverBox] AS Expr18, " & _
"[Forms]![Form_Charter_Redesign]![DetailsBox] AS Expr19, " & _
"[Forms]![Form_Charter_Redesign]![EventPaidFullBox] AS Expr20, " & _
"[Forms]![Form_Charter_Redesign]![DatePaidBox] AS Expr21, " & _
"[Forms]![Form_Charter_Redesign]![VehicleBox] AS Expr22"
DoCmd.RunSQL (strSQL)
' Base Sub Calls (Sends an email to the proper base based on Branch Combo Box)
If Me.ComboBranch.Value = "Gowanda" Then
Call send_Gowanda
End If
If Me.ComboBranch.Value = "Lancaster" Then
Call send_Lancaster
End If
If Me.ComboBranch.Value = "Hamburg" Then
Call send_Hamburg
End If
If Me.ComboBranch.Value = "Tonawanda" Then
Call send_Tonawanda
End If
If Me.ComboBranch.Value = "Olean" Then
Call send_Olean
End If
If Me.ComboBranch.Value = "Jamestown" Then
Call send_Jamestown
End If
If IsNull(Me.ComboBranch.Value) Then
Call send_BaseNull
End If
End Sub
Sub send_Gowanda()
Dim EmailTo As String
Dim EmailCC As String
EmailTo = "Test@email.com"
EmailCC = "Test@email.com"
DoCmd.SendObject acReport, stDocName, "PDFFormat(*.pdf)", EmailTo, EmailCC, "", "New Gowanda Charter Submission", "A new charter has been submitted. Attached is a copy for your convenience.", True, ""
End Sub
Sub send_Lancaster()
Dim EmailTo As String
Dim EmailCC As String
EmailTo = "Test@email.com"
EmailCC = "Test@email.com"
DoCmd.SendObject acReport, stDocName, "PDFFormat(*.pdf)", EmailTo, EmailCC, "", "New Lancaster Charter Submission", "A new charter has been submitted. Attached is a copy for your convenience.", True, ""
End Sub
Sub send_Hamburg()
Dim EmailTo As String
Dim EmailCC As String
EmailTo = "Test@email.com"
EmailCC = "Test@email.com"
DoCmd.SendObject acReport, stDocName, "PDFFormat(*.pdf)", EmailTo, EmailCC, "", "New Hamburg Charter Submission", "A new charter has been submitted. Attached is a copy for your convenience.", True, ""
End Sub
Sub send_Tonawanda()
Dim EmailTo As String
Dim EmailCC As String
EmailTo = "Test@email.com"
EmailCC = "Test@email.com"
DoCmd.SendObject acReport, stDocName, "PDFFormat(*.pdf)", EmailTo, EmailCC, "", "New Tonawanda Charter Submission", "A new charter has been submitted. Attached is a copy for your convenience.", True, ""
End Sub
Sub send_Olean()
Dim EmailTo As String
Dim EmailCC As String
EmailTo = "Test@email.com"
EmailCC = "Test@email.com"
DoCmd.SendObject acReport, stDocName, "PDFFormat(*.pdf)", EmailTo, EmailCC, "", "New Olean Charter Submission", "A new charter has been submitted. Attached is a copy for your convenience.", True, ""
End Sub
Sub send_Jamestown()
Dim EmailTo As String
Dim EmailCC As String
EmailTo = "Test@email.com"
EmailCC = "Test@email.com"
DoCmd.SendObject acReport, stDocName, "PDFFormat(*.pdf)", EmailTo, EmailCC, "", "New Jamestown Charter Submission", "A new charter has been submitted. Attached is a copy for your convenience.", True, ""
End Sub
Sub send_BaseNull()
MsgBox "You must specify a Branch for this Charter!"
End Sub