Hello everyone I found a way to include SQL code into VBA without creating a query here is my code, but my problem is if I try to run it says there has to be an SQL statement in order to use the DoCmd.RunSql but clearly the SQL statement is within the variable strSQL here is the code.
Private Sub buttonNot_Click()
Dim strSQL As String
strSQL = "SELECT Table1.[FirstNam], Table1.[LastNam]" & _
"FROM Table1 " & _
"WHERE ((([FirstNam]) <> 'Jamie') AND (([LastNam]) <> 'Cartman'));"
DoCmd.RunSQL strSQL
Me.Filter = ""
Me.Filter = "FirstNam<>'Jamie' AND Lastnam<>'Cartman'"
End Sub