Below is a code that I have for Excel. I would like to use it in an Access database to clear rows that match both the Client number and specific date. It works well in excel. -no errors. Can this be placed in Access and called by a button to open a table and preform the same as calling it as a macro in excel? If so how would I do that? -open a page with the button then run the code. What would the open and run command be for a table named "#comments" ?
Sub ClearImports() Application.ScreenUpdating = False ActiveSheet.AutoFilterMode = False Dim ClientNumber As String, EntryDate As String Dim FilterRange As Range, DeleteRange As Range Client = InputBox("Enter Client Number", "Client") Entry = InputBox("Enter Entry Date", "Date") Application.ScreenUpdating = False ActiveSheet.AutoFilterMode = False Set FilterRange = Range(("A1"), Cells(Rows.Count, 1).End(xlUp).Offset(0, 5)) Set DeleteRange = Range(("A2"), Cells(Rows.Count, 1).End(xlUp).Offset(0, 5)) With FilterRange .AutoFilter Field:=1, Criteria1:=Client .AutoFilter Field:=4, Criteria1:=Entry, Operator:=xlAnd End With On Error Resume Next DeleteRange.SpecialCells(xlCellTypeVisible).EntireRow.Delete ActiveSheet.AutoFilterMode = False Application.ScreenUpdating = True Set FilterRange = Nothing Set DeleteRange = Nothing End Sub