I am trying to update an older MS Access 2010 VBA script that is embedded into a button click. This button will update another Access table for another squadron. I need to change a couple things around however because my update will basically break this script by not sending all the required information.
What needs to be done is there is a "Top3Commen ts" and a "Call Sign" entry that have their own boxes. What I have updated is now requiring the "Top3Commen ts" to be concatenated with the mission commander "Commander" and the "Call Sign" to be concatenated with "C/S_Number". I need the combined output of both of those to output to a single cell in the table.
I am assuming that I will just use a JOIN function after calling all variables into a Dim? I am not really sure how to accomplish this though. Anyone have any ideas.
This is the current code that I have.
What needs to be done is there is a "Top3Commen ts" and a "Call Sign" entry that have their own boxes. What I have updated is now requiring the "Top3Commen ts" to be concatenated with the mission commander "Commander" and the "Call Sign" to be concatenated with "C/S_Number". I need the combined output of both of those to output to a single cell in the table.
I am assuming that I will just use a JOIN function after calling all variables into a Dim? I am not really sure how to accomplish this though. Anyone have any ideas.
Code:
Private Sub Btn_Update_Top_3_Buddy_Click() 'When you click the Update button, this procedure will delete the selected day's comments in the [TOP 3 LOG Table] 'And then add the current mission comments to the [TOP 3 LOG Table]. On Error GoTo Err_Btn_Report_Click Dim DeleteQuery As String Dim InsertQuery As String DoCmd.SetWarnings False DeleteQuery = "DELETE [TOP 3 LOG Table].Squadron, [TOP 3 LOG Table].Date FROM [TOP 3 LOG Table] " _ & "WHERE (((([TOP 3 LOG Table].Squadron='489 RS')OR([TOP 3 LOG Table].Squadron='427 RS')OR([TOP 3 LOG Table].Squadron='306 IS')))" _ & "AND (([TOP 3 LOG Table].Date)=#" & Forms![Ops Sup]![Date_SITREP] & "#));" DoCmd.RunSQL DeleteQuery InsertQuery = "INSERT INTO [TOP 3 LOG Table] ( [Date], Squadron, Top3Name, Top3Comments, " _ & "[Line#], Aircraft, Block, SortieType, [NE/CNX], Reason, FlightTime, [Call Sign], [Tail#]) " _ & "SELECT Missions.Date_Mission, Missions.Squadron, Missions.Top3Name, Missions.Top3Comments, " _ & "Missions.[Line#], Missions.Aircraft, Missions.Block, Missions.[Sortie Type], Missions.[NE/CNX], " _ & "Missions.Reason, Missions.FlightTime, Missions.[Call Sign], Missions.[Tail#] " _ & "FROM Missions " _ & "WHERE (((Missions.Date_Mission)= #" & Forms![Ops Sup]![Date_SITREP] & "#));" DoCmd.RunSQL InsertQuery DoCmd.SetWarnings True MsgBox ("Top 3 Buddy updated.") Exit_Btn_Report_Click: Exit Sub Err_Btn_Report_Click: DoCmd.SetWarnings True MsgBox Err.Description End Sub
Comment