Hi Everyone,
I am a newbie in this forum. I am currently working on a access db that has multiple forms/Queries/Tables.
The form that I am working on, comes from a Query. The information in the form is re filtered based on date range. Then, the remaining results need to be filtered based on a specific value from one of the fields [Quantity]. I added a group option to the form, so it can show the specific values that I am looking form based on date/range and Quantity. However, it's not working properly, so I am missing something here.
Can anyone take a look at this and provide some help? Much appreciated:
Here is the code for the date range:
Private Sub cmdsearch_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 = "([Ship date] >= #" & Me.OrderDatefrom & " # And [Ship date]<= #" & Me.Orderdateto & "#)"
task = "Select * From QryIntransit where (" & strCriteria & ") order by [Ship date]"
DoCmd.ApplyFilter task
End If
End Sub
And here is the VBA code for the option Group:
Private Sub Frame1_Click()
Dim strFilter As Integer
Select Case Frame1
Case 1
strFilter = "[Quantity] < = '50000'"
Forms!frmInTransit.Form.Filter = strFilter
Forms!frmInTransit.Form.FilterOn = True
Case 2
strFilter = "[Quantity] > = '50000'"
Forms!frmInTransit.Form.Filter = strFilter
Forms!frmInTransit.Form.FilterOn = True
End Select
End Sub
I am a newbie in this forum. I am currently working on a access db that has multiple forms/Queries/Tables.
The form that I am working on, comes from a Query. The information in the form is re filtered based on date range. Then, the remaining results need to be filtered based on a specific value from one of the fields [Quantity]. I added a group option to the form, so it can show the specific values that I am looking form based on date/range and Quantity. However, it's not working properly, so I am missing something here.
Can anyone take a look at this and provide some help? Much appreciated:
Here is the code for the date range:
Private Sub cmdsearch_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 = "([Ship date] >= #" & Me.OrderDatefrom & " # And [Ship date]<= #" & Me.Orderdateto & "#)"
task = "Select * From QryIntransit where (" & strCriteria & ") order by [Ship date]"
DoCmd.ApplyFilter task
End If
End Sub
And here is the VBA code for the option Group:
Private Sub Frame1_Click()
Dim strFilter As Integer
Select Case Frame1
Case 1
strFilter = "[Quantity] < = '50000'"
Forms!frmInTransit.Form.Filter = strFilter
Forms!frmInTransit.Form.FilterOn = True
Case 2
strFilter = "[Quantity] > = '50000'"
Forms!frmInTransit.Form.Filter = strFilter
Forms!frmInTransit.Form.FilterOn = True
End Select
End Sub