Assuming you have some button to call the change of RecordSource for Data2 (in this example the button is called, cmdShowDate) you can use this code. You don't need to worry about date formating. If Access receives this query it will still understand the correct date range (infact using a three character code for the date assures you of getting the correct date, with no dd/mm confusion).
You may have to play around with the quote characters surrounding the dates in the query. Access doesn't use standard SQL for all things. To run this with Access you may have to try things like: the # character. eg:Code:Private Sub cmdShowDate_Click() Dim strStartDate As String Dim strEndDate As String strStartDate = Format("10/4/94", "dd mmm yyyy") strEndDate = Format("01 " & cboMonth & " " & cboYear, "dd mmm yyyy") If CDate(strStartDate) < CDate(strEndDate) Then txtDate.Text = "SELECT * " _ & "FROM MASTER " _ & "WHERE DATE_OPENED BETWEEN '" & strStartDate & "' AND '" & strEndDate & "'" Data2.RecordSource = txtDate.Text Data2.Recordset.MoveFirst Else txtDate.Text = "Records do not go back to: " & strEndDate End If End Sub
Experiment a bit. This code does work I've used it myself many times before.Code:txtDate.Text = "SELECT * " _ & "FROM MASTER " _ & "WHERE DATE_OPENED BETWEEN #" & strStartDate & "# AND #" & strEndDate & "#"
[Edited by Pactor1 on 04-12-2000 at 10:07 PM]




Reply With Quote