bees292
08-11-2005, 04:02 PM
I've got a query that does exactly what this (http://www.access-programmers.co.uk/forums/showthread.php?t=89564&highlight=null+records) chap got his to do.
However I want to add a "*" character to the criteria to allow for searches with partial matches. Here's the criteria that works:
[title]=[Forms].[Search]![Title] Or [Forms].[Search]![Title] Is Null
However when I try the logical extension:
[title]=[Forms].[Search]![Title] & "*" Or [Forms].[Search]![Title] Is Null
this doesn't work, and nor does:
[title]=([Forms].[Search]![Title] & "*") Or [Forms].[Search]![Title] Is Null
WHAT DO I DO? I'M TIRED AND I CANT THINK STRAIGHT! :eek: thanks and sorry for being so dumb!
TessB
08-11-2005, 05:46 PM
Did you try
[title] Like [Forms].[Search]![Title] & "*"
instead of =
bees292
08-12-2005, 01:59 AM
Yes I have tried that. The difference between that and the one above is that the 'Like.... & "*"' doesn't include null records.
This is what I want it to do:
3 fields (for now)
Field A
Field B
Field C
If I enter text into fields A and B I want it to search using criteria for just those fields (ignoring C), and this is what the 1st bit of my 1st post does. I now want to add a wild card function to each search field so I can search for all records matching in part. e.g.,
Search Bloggs - return records for bloggsy, bloggydodah etc.
Your expression [title] Like [Forms].[Search]![Title] & "*" does in fact do that but will not include null records.
TessB
08-12-2005, 06:21 AM
If you want to include Null records, wouldn't you use
[title] Like "*" & [Forms].[Search]![Title] & "*" OR [title] Is Null OR [Forms].[Search]![Title] Is Null Or [Forms].[Search]![Title] Like ""
This is saying;
Return all records in which the title field includes anything entered in the form's input box, include records where the title field is null, and if the Form field is blank, return all records.
bees292
08-12-2005, 06:43 AM
I thought you couldn't use Is Null with Like?
TessB
08-12-2005, 10:07 AM
You can't say [title] Like Is Null.
You can say [title] Like "" OR [title] Is Null.
bees292
08-13-2005, 08:49 AM
If you want to include Null records, wouldn't you use
[title] Like "*" & [Forms].[Search]![Title] & "*" OR [title] Is Null OR [Forms].[Search]![Title] Is Null Or [Forms].[Search]![Title] Like ""
This is saying;
Return all records in which the title field includes anything entered in the form's input box, include records where the title field is null, and if the Form field is blank, return all records.
That works well. Thank you very much!