alfonsomozo
Technical User
I have created a table with a list of clients and their details.
I have then set-up a form with alot of free text boxes to search each specific field. This works well unless there is one blank field for the entire record. If this is the case i can not get the record to turn up no matter what. At the moment I am using
Like "*" & [Forms]![Search]![City] & "*"
The only way i can get it to return all records is to modify the above statement to
Like "*" & [Forms]![Search]![City] & "*" OR is null
This works but if i search specifically for a City and the City field is left blank for a number of records their results will always be returned.
I was hoping to use an IIF statement but i was having trouble getting it to work, ideally i would like to use
IIf([Forms]![Search]![FirstName] Is Null,Is Null Or Like "*",Like "*" & [Forms]![Search]![FirstName] & "*")
which should work because if i type in manually
is null OR "*" all results are returned.
Access for some reason changes this to
IIf([Forms]![Search]![FirstName] Is Null,([Contacts].[FirstName]) Is Null Or ([Contacts].[FirstName]) Like "*",([Contacts].[FirstName]) Like "*" & [Forms]![Search]![FirstName] & "*") which consequently causes the query not to return anything.
Basically is there a way to change the query to work or is there an easy way to change the set-up of my tables so as opposed to being NULL when no value is entered they will instead have have the value "" which will be returned with "*".
thanks in advance.
Alex.
I have then set-up a form with alot of free text boxes to search each specific field. This works well unless there is one blank field for the entire record. If this is the case i can not get the record to turn up no matter what. At the moment I am using
Like "*" & [Forms]![Search]![City] & "*"
The only way i can get it to return all records is to modify the above statement to
Like "*" & [Forms]![Search]![City] & "*" OR is null
This works but if i search specifically for a City and the City field is left blank for a number of records their results will always be returned.
I was hoping to use an IIF statement but i was having trouble getting it to work, ideally i would like to use
IIf([Forms]![Search]![FirstName] Is Null,Is Null Or Like "*",Like "*" & [Forms]![Search]![FirstName] & "*")
which should work because if i type in manually
is null OR "*" all results are returned.
Access for some reason changes this to
IIf([Forms]![Search]![FirstName] Is Null,([Contacts].[FirstName]) Is Null Or ([Contacts].[FirstName]) Like "*",([Contacts].[FirstName]) Like "*" & [Forms]![Search]![FirstName] & "*") which consequently causes the query not to return anything.
Basically is there a way to change the query to work or is there an easy way to change the set-up of my tables so as opposed to being NULL when no value is entered they will instead have have the value "" which will be returned with "*".
thanks in advance.
Alex.