Hi My Name is Jon
I will simplifie my problem
I created the following to use the form as a search tool to search the query
I created a table(table1) and a query(query1) for that table and a form(SearchForm) for that query(table->query->form)
In the table there is only 2 fields. filed1 is always filled(NOT Null) and field2 is empty sometimes(Null)
when I first created the search form I put the following code in the query desing window under the criteria row.
The problem with this code is that if there is an an empty(null) field under field2 the search will not return the record with the empty field. For example: I search for "abc" for field1 and there is 2 records that mach "abc" but one of those records has field2 empty(Null), the search will only return 1 record, the one that has both fields filled. the record that has field2 empty is left out.
To partially fix this I wrote the following code for field2:
this code is not perfect because now when i search "abc" for field1 it will return the 2 records but now it will ALSO return any records that have field 2 empty(null) even if they have nothing to do with "abc"
Thats why I am here I tried IFF functions to tried to fix this but My code skills are poor. maybe someone in this forum can shine some light in the direction I should be heading now.
this is the code I tried to fix this
than you in advance
I will simplifie my problem
I created the following to use the form as a search tool to search the query
I created a table(table1) and a query(query1) for that table and a form(SearchForm) for that query(table->query->form)
In the table there is only 2 fields. filed1 is always filled(NOT Null) and field2 is empty sometimes(Null)
when I first created the search form I put the following code in the query desing window under the criteria row.
Code:
For field1:
Like "*" & [Forms]![SearchForm]![Field1] & "*"
For field2:
Like "*" & [Forms]![SearchForm]![Field2] & "*"
To partially fix this I wrote the following code for field2:
Code:
Like "*" & [Forms]![SearchForm]![Field2] & "*" Or Is Null
this code is not perfect because now when i search "abc" for field1 it will return the 2 records but now it will ALSO return any records that have field 2 empty(null) even if they have nothing to do with "abc"
Thats why I am here I tried IFF functions to tried to fix this but My code skills are poor. maybe someone in this forum can shine some light in the direction I should be heading now.
this is the code I tried to fix this
Code:
IIf ([Forms]![SearchForm]![Field2]= "",
Like "*" & [Forms]![SearchForm]![Field2] & "*" or Is Null,
Like "*" & [Forms]![SearchForm]![Field2] & "*")
And I tried this:
IIf ([Forms]![SearchForm]![Field2] = Null,
Like "*" & [Forms]![SearchForm]![Field2] & "*" or Is Null,
Like "*" & [Forms]![SearchForm]![Field2] & "*")
Also tried this but it gives me a error code when
i run the query(I think because "*" means both if is empty or has text in it)
IIf ([Forms]![SearchForm]![Field2] = "*",
Like "*" & [Forms]![SearchForm]![Field2] & "*",
Like "*" & [Forms]![SearchForm]![Field2] & "*" or Is Null)
than you in advance