Running Parameter Queries
Sub RunParameterQuery(datStart As Date, datEnd As Date) Dim cmd As ADODB.Command Dim rst As ADODB.Recordset Set cmd = New ADODB.Command cmd.ActiveConnection = CurrentProject.Connection cmd.CommandText = "Select * from Employees " & _ "Where BirthDate Between ? and ?" cmd.CommandType = adCmdText Set rst = cmd.Execute(Parameters:=Array(datStart, datEnd)) Do Until rst.EOF Debug.Print rst("EmployeeID"), rst("BirthDate") rst.MoveNext Loop rst.Close Set rst = Nothing Set cmd = Nothing End Sub