Okay here goes
I have a search form based on a my problems form. I have a command button which you click when you have selected or filled in the boxes you wish to search on. The code behind this button is....Private Sub cmdSearch_Click()
Dim CSearch, cFilter As String
Dim rsAims As ADODB.Recordset
Dim csql As String
cFilter = ""
CSearch = ""
If Me.txtAimID <> "" Then
CSearch = CSearch + "AimID='" + txtAimID.Text + "'"
End If
If Me.cboAimType <> "" Then
If Len(CSearch) > 0 Then
CSearch = CSearch + " and "
End If
CSearch = CSearch + "AimType='" + cboAimType + "'"
End If
If Me.mmAimDescription <> "" Then
If Len(CSearch) > 0 Then
CSearch = CSearch + " and "
End If
CSearch = CSearch + "AimDescription Like '* " _
& mmAimDescription & " *'"
End If
Set rsAims = New ADODB.Recordset
csql = "select AimID from qryProblemActions where " + _ CSearch
rsAims.Open csql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If rsAims.RecordCount > 0 Then rsAims.MoveFirst
If rsAims.RecordCount = 0 Then
MsgBox "No records met your criteria"
Else
Do While Not rsAims.EOF
If Len(cFilter) > 0 Then
cFilter = cFilter + " or "
End If
cFilter = cFilter + "AimID =" + Str(rsAims!AimID)
rsAims.MoveNext
Loop
DoCmd.OpenForm "frmProblems", acNormal, , cFilter
End If
End Sub
While stepping through the code and hovering over the values it looks correct but it does not bring any records through although I know there is two. Can anyone see what I am doing wrong?
Thanks.... a desperate user