chris-uk-lad
Registered User.
- Local time
- Today, 13:45
- Joined
- Jul 8, 2008
- Messages
- 271
Hi all.
I am using a form that checks a table for results based on the cirteria entered in the textboxs provided. This currently works fine for a table i have where all 4 columns are populated. Im now using a table that has many null values, yet running the same code only returns values where there are no nulls, and not all like i wish.
e.g if i click the search button at the start of the tool (with empty textboxs should return all records) it only returns 3 records (as these have all 4 columns populated in the table) and doesnt show the remaining ones as Forename and Reference are Null for these. I think the problem resides in the SQL im running to the table shown below.
You will likely question the strSQL line using strWhere within, was for ease.
All help appreciated, thanks
I am using a form that checks a table for results based on the cirteria entered in the textboxs provided. This currently works fine for a table i have where all 4 columns are populated. Im now using a table that has many null values, yet running the same code only returns values where there are no nulls, and not all like i wish.
e.g if i click the search button at the start of the tool (with empty textboxs should return all records) it only returns 3 records (as these have all 4 columns populated in the table) and doesnt show the remaining ones as Forename and Reference are Null for these. I think the problem resides in the SQL im running to the table shown below.
Code:
If IsNull(Surname) Then
strSurname = "SURNAME LIKE '*'"
Else
strSurname = "SURNAME LIKE '" & Surname & "*'"
End If
If IsNull(FORENAME) Then
strForename = "FORENAME LIKE '*'"
Else
strForename = "FORENAME LIKE '" & FORENAME & "*'"
End If
If IsNull(DATE) Then
strDate = "Date LIKE '*'"
Else
strDate = "Date ='" & Format(DATE, "YYYY-MM-DD") & "'"
End If
If IsNull(Ref) Then
strOtherRef = "Ref LIKE '*'"
Else
strOtherRef = "Ref = '" & Ref & "'"
End If
strWhere = "WHERE " & strSurname & " AND " & strForename & " AND " & strDate & " AND " & strRef
strSQL = "SELECT * FROM tblMember " & strWhere & " ORDER BY SURNAME, FORENAME"
You will likely question the strSQL line using strWhere within, was for ease.
All help appreciated, thanks
Last edited: