I am having some trouble with filtering.
I have a form that has 6 subforms. The main form has 2 combo boxes that are stations along a road corridor. the filter is supposed to return the values from all 6 subforms that have stations between the 2 combo box stations.
It sort of works: I am getting all of the data up to the value that is in the second combo box instead of getting all of the data between the two combo boxes.
Here is the code that I have
Option Compare Database
Option Explicit
Private Sub cmdFilter_Click()
Dim strFilter As String
Dim lngLen As Long
If Not IsNull(Me.cboSouthernIRP) Then
strFilter = strFilter & "[IRP 2006 Station] = """ & Me.cboSouthernIRP & """ OR "
End If
If Not IsNull(Me.cboSouthernIRP) Then
strFilter = strFilter & "[IRP 2006 Station] > """ & Me.cboSouthernIRP & """ AND "
End If
If Not IsNull(Me.cboNorthernIRP) Then
strFilter = strFilter & "[IRP 2006 Station] = """ & Me.cboNorthernIRP & """ OR "
End If
If Not IsNull(Me.cboNorthernIRP) Then
strFilter = strFilter & "[IRP 2006 Station] < """ & Me.cboNorthernIRP & """ AND "
End If
lngLen = Len(strFilter) - 5
If lngLen <= 0 Then
MsgBox "No Criteria", vbInformation, "Nothing to do."
Else
strFilter = Left$(strFilter, lngLen)
Me.Filter = strFilter
Me.FilterOn = True
End If
End Sub
Private Sub cmdReset_Click()
Dim ctl As Control
For Each ctl In Me.Section(acHeader).Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox
ctl.Value = Null
End Select
Next
Me.FilterOn = False
End Sub
Private Sub Form_BeforeInsert(Cancel As Integer)
Cancel = True
MsgBox "You cannot add new data to this form", vbInformation, "Permission Denied"
End Sub
I don't understand why the <= part would work but not the >= part...
I have used this forum a lot in the past few weeks and I was only able to get this far using the help that all of you have given to other people...Thanks a lot!
I have a form that has 6 subforms. The main form has 2 combo boxes that are stations along a road corridor. the filter is supposed to return the values from all 6 subforms that have stations between the 2 combo box stations.
It sort of works: I am getting all of the data up to the value that is in the second combo box instead of getting all of the data between the two combo boxes.
Here is the code that I have
Option Compare Database
Option Explicit
Private Sub cmdFilter_Click()
Dim strFilter As String
Dim lngLen As Long
If Not IsNull(Me.cboSouthernIRP) Then
strFilter = strFilter & "[IRP 2006 Station] = """ & Me.cboSouthernIRP & """ OR "
End If
If Not IsNull(Me.cboSouthernIRP) Then
strFilter = strFilter & "[IRP 2006 Station] > """ & Me.cboSouthernIRP & """ AND "
End If
If Not IsNull(Me.cboNorthernIRP) Then
strFilter = strFilter & "[IRP 2006 Station] = """ & Me.cboNorthernIRP & """ OR "
End If
If Not IsNull(Me.cboNorthernIRP) Then
strFilter = strFilter & "[IRP 2006 Station] < """ & Me.cboNorthernIRP & """ AND "
End If
lngLen = Len(strFilter) - 5
If lngLen <= 0 Then
MsgBox "No Criteria", vbInformation, "Nothing to do."
Else
strFilter = Left$(strFilter, lngLen)
Me.Filter = strFilter
Me.FilterOn = True
End If
End Sub
Private Sub cmdReset_Click()
Dim ctl As Control
For Each ctl In Me.Section(acHeader).Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox
ctl.Value = Null
End Select
Next
Me.FilterOn = False
End Sub
Private Sub Form_BeforeInsert(Cancel As Integer)
Cancel = True
MsgBox "You cannot add new data to this form", vbInformation, "Permission Denied"
End Sub
I don't understand why the <= part would work but not the >= part...
I have used this forum a lot in the past few weeks and I was only able to get this far using the help that all of you have given to other people...Thanks a lot!