Here is my code. I'd really appreciate any help I can get.
Expand|Select|Wrap|Line Numbers
- Private Sub cmdSearch_Click()
- Dim strWhere As String
- Dim lngLen As Long
- If Not IsNull(Me.cboSearchLastName) Then
- strWhere = strWhere & "[LastName] ='" & Me.cboSearchLastName & "' AND "
- End If
- If Not IsNull(Me.cboSearchFirstName) Then
- strWhere = strWhere & "[FirstName] ='" & Me.cboSearchFirstName & "' AND "
- End If
- If Not IsNull(Me.cboSearchOrganization) Then
- strWhere = strWhere & "[OrganizationFK] =" & Me.cboSearchOrganization & " AND "
- End If
- If Not IsNull(Me.cboSearchShopName) Then
- strWhere = strWhere & "[ShopNameFK] =" & Me.cboSearchShopName & " AND "
- End If
- If Not IsNull(Me.cboSearchOfficeSym) Then
- strWhere = strWhere & "[OfficeSymFK] =" & Me.cboSearchOfficeSym & " AND "
- End If
- If Not IsNull(Me.cboSearchBuildingName) Then
- strWhere = strWhere & "[BuildingFK] =" & Me.cboSearchBuildingName & " AND "
- End If
- If Not IsNull(Me.cboSearchRoomName) Then
- strWhere = strWhere & "[RoomsPK] =" & Me.cboSearchRoomName & " AND "
- End If
- Call MsgBox(strWhere, vbOKOnly, "Debug")
- lngLen = Len(strWhere) - 5
- If lngLen <= 0 Then
- MsgBox "No criteria", vbInformation, "Nothing to do."
- Else
- strWhere = Left$(strWhere, lngLen)
- Call MsgBox(strWhere, vbOKOnly, "Debug")
- ' MsgBox "No Records Found."
- Dim Msg As VbMsgBoxResult
- If DCount("*", "qryRecordSet", strWhere) = 0 Then
- Msg = MsgBox("No corresponding records to your search criteria." & vbCrLf & vbCrLf & _
- "Okay", vbCritical + vbYesNo)
- If Msg = vbYes Then
- Me.FilterOn = False
- Me.cboSearchBuildingName = ""
- Me.cboSearchRoomName = ""
- Me.cboSearchOrganization = ""
- Me.cboSearchShopName = ""
- Me.cboSearchOfficeSym = ""
- Me.cboSearchLastName = ""
- Me.cboSearchFirstName = ""
- Else
- Me.Filter = strWhere
- Me.FilterOn = True
- End If
- End If