I have a main form with combo boxes to filter a subform. I want to be able to export the filtered subform data to a table within the database and only include the filtered dataset not all records. I'm new to VB code and need some help. TIA
Private Sub cmdAddToTable_Click()
Dim tmpSQL As String
tmpSQL = Me.subFormName.Form.RecordSource
CurrentDb.Execute("INSERT INTO theTableName (theFieldListInTheSubForm)" & tmpSQL)
End Sub
Private Sub cmdAddToTable_Click()
Dim tmpSQL As String
tmpSQL = Me.frmPacsVerificationSubForm.Form.RecordSource
tmpSQL = "INSERT INTO tblResultsTracking (ID, Business_Line)" & tmpSQL
Debug.Print tmpSQL
CurrentDb.Execute tmpSQL
End Sub
Private Sub cmdAddToTable_Click()
Dim tmpRS As DAO.Recordset, tmpSQL As String
Set tmpRS = Me.frmPacsVerificationSubForm.Form.RecordSetClone
If tmpRS.RecordCount > 0 Then
Do While Not tmpRS.EOF
tmpSQL = "INSERT INTO tblResultsTracking (ID, Business_Line) VALUES (" & tmpRS!ID & ", '" & tmpRS!Business_Line & "')"
CurrentDb.Execute tmpSQL
tmpRS.MoveNext
Loop
End If
Set tmpRS = Nothing
End Sub
Private Sub cmdAddToTable_Click()
Dim tmpRS As DAO.Recordset, tmpSQL As String
Set tmpRS = Me.frmPacsVerificationSubForm.Form.RecordsetClone
If tmpRS.RecordCount > 0 Then
Do While Not tmpRS.EOF
tmpSQL = "INSERT INTO tblResultsTracking (Template_ID, Template_Name, Payment_Type_Description, Created_Date,Approved Date,Approved ADENT,Business_Line, ID) VALUES (" & tmpRS!Template_ID & ",[COLOR=Red][B]'[/B][/COLOR]" & tmpRS!Template_Name & "[COLOR=Red][B]'[/B][/COLOR],[COLOR=Red][B]'[/B][/COLOR]" & tmpRS!Payment_Type_Description & "[COLOR=Red][B]'[/B][/COLOR],[COLOR=Red][B]#[/B][/COLOR]" & tmpRS!Created_Date & "[COLOR=Red][B]#[/B][/COLOR],[COLOR=Red][B]#[/B][/COLOR]" & tmpRS!Approved_Date & "[COLOR=Red][B]#[/B][/COLOR],[COLOR=Red][B]'[/B][/COLOR]" & tmpRS!Approved_ADENT & "[COLOR=Red][B]'[/B][/COLOR],[COLOR=Red][B]'[/B][/COLOR]" & tmpRS!Business_Line & "[COLOR=Red][B]'[/B][/COLOR])"
CurrentDb.Execute tmpSQL
tmpRS.MoveNext
Loop
End If
Set tmpRS = Nothing
End Sub
tmpSQL = "INSERT INTO tblResultsTracking (Template_ID, Template_Name, Payment_Type_Description, Created_Date, Approved_Date, Approved_ADENT, " & _
"Business_Line, ID, Updated_Date, Created_Name, Open_By_AU, Initiated_ADENT, Initiated_Name, Approved_Name, Memo1, Memo2, Memo3) VALUES ('" & _
tmpRS!Template_ID & "','" & tmpRS!Template_Name & "','" & tmpRS!Payment_Type_Description & "',#" & tmpRS!Created_Date & "#,#" & _
tmpRS!Approved_Date & "#,'" & tmpRS!Approved_ADENT & "','" & tmpRS!Business_Line & "','" & tmpRS!ID & "', #" & tmpRS!Updated_Date & "#,'" & _
tmpRS!Created_Name & "', '" & tmpRS!Open_By_AU & "', '" & tmpRS!Initiated_ADENT & "', '" & tmpRS!Initiated_Name & "', '" & tmpRS!Approved_Name & _
"', '" & tmpRS!Memo1 & "', '" & tmpRS!Memo2 & "', '" & tmpRS!Memo3 & "')"
Private Sub cmdAddToTable_Click()
Dim tmpRS As DAO.Recordset, tmpSQL As String
Set tmpRS = Me.frmPacsVerificationSubForm.Form.RecordsetClone
If tmpRS.RecordCount > 0 Then
Do While Not tmpRS.EOF
tmpSQL = "INSERT INTO tblResultsTracking (Template_ID, Template_Name, Payment_Type_Description, Created_Date, Approved_Date, Approved_ADENT, " & _
"Business_Line, ID, Updated_Date, Created_Name, Open_By_AU, Initiated_ADENT, Initiated_Name, Approved_Name, Memo1, Memo2, Memo3) VALUES ('" & _
tmpRS!Template_ID & "','" & tmpRS!Template_Name & "','" & tmpRS!Payment_Type_Description & "',#" & tmpRS!Created_Date & "#,#" & _
tmpRS!Approved_Date & "#,'" & tmpRS!Approved_ADENT & "','" & tmpRS!Business_Line & "','" & tmpRS!ID & "', #" & tmpRS!Updated_Date & "#,'" & _
tmpRS!Created_Name & "', '" & tmpRS!Open_By_AU & "', '" & tmpRS!Initiated_ADENT & "', '" & tmpRS!Initiated_Name & "', '" & tmpRS!Approved_Name & _
"', '" & tmpRS!Memo1 & "', '" & tmpRS!Memo2 & "', '" & tmpRS!Memo3 & "')"
[COLOR=Red][B]Debug.Print tmpSQL[/B][/COLOR]
CurrentDb.Execute tmpSQL
tmpRS.MoveNext
Loop
End If
Set tmpRS = Nothing
End Sub