Hi,
I’m complete beginner challenging myself, getting relevant things I want to achieve from the internet and now this forum – I’ve managed to get this VBA below to work to a point. I’ve worked out that my dates which are UK format are treated as US format giving me random results (I can see why) BUT - Can anyone help how I can change this?
_______________________________________________
Option Compare Database
Private Sub Command12_Click()
' search button
Call search
End Sub
Sub search()
Dim strCriteria, task As String
Me.Refresh
If IsNull(Me.OrderDateFrom) Or IsNull(Me.OrderDateTo) Then
MsgBox "Please enter the date range", vbInformation, "Date Range Required"
Me.OrderDateFrom.SetFocus
Else
strCriteria = "([Order Date] between #" & Me.OrderDateFrom & "# And #" & Me.OrderDateTo & "#)"
task = "Select * from Table1 where (" & strCriteria & ") order by [Order Date]"
DoCmd.ApplyFilter task
End If
End Sub
I’m complete beginner challenging myself, getting relevant things I want to achieve from the internet and now this forum – I’ve managed to get this VBA below to work to a point. I’ve worked out that my dates which are UK format are treated as US format giving me random results (I can see why) BUT - Can anyone help how I can change this?
_______________________________________________
Option Compare Database
Private Sub Command12_Click()
' search button
Call search
End Sub
Sub search()
Dim strCriteria, task As String
Me.Refresh
If IsNull(Me.OrderDateFrom) Or IsNull(Me.OrderDateTo) Then
MsgBox "Please enter the date range", vbInformation, "Date Range Required"
Me.OrderDateFrom.SetFocus
Else
strCriteria = "([Order Date] between #" & Me.OrderDateFrom & "# And #" & Me.OrderDateTo & "#)"
task = "Select * from Table1 where (" & strCriteria & ") order by [Order Date]"
DoCmd.ApplyFilter task
End If
End Sub