G
Guest
I have an form setup that you can type information to use as a search. For
example to see all the contracts for a specific Assigned Resource you can
just type in the Assigned Resourse and click search. However, my problem is
when one of the search fields is left blank. I do not get the results I
need. I want the query to use the information entered into the form but alow
anything in the fields that are left null.
I have 20 feilds you can search by but I only included two because of length.
My first try:
SELECT [JFWorkflow Main Table].CN_PN, [JFWorkflow Main Table].[Assigned
Resource]
FROM [JFWorkflow Main Table]
WHERE ((([JFWorkflow Main
Table].CN_PN)=If([Forms]![Search]![CN_PN]<>"",([JFWorkflow Main
Table].[CN_PN]) Like [Forms]![Search]![CN_PN] & "*","")) AND (([JFWorkflow
Main Table].[Assigned Resource])=If([Forms]![Search]![Assigned
Resource]<>"",([JFWorkflow Main Table].[Assigned Resource]) Like
[Forms]![Search]![Assigned Resource] & "*","")));
But I do not get any results if a field is left blank. I assume I need
something else in the "false" field of the "if" statement.
Here is my other try:
SELECT [JFWorkflow Main Table].CN_PN, [JFWorkflow Main Table].[Assigned
Resource]
FROM [JFWorkflow Main Table]
WHERE ((([JFWorkflow Main Table].CN_PN) Like [Forms]![Search]![CN_PN] & "*"
Or ([JFWorkflow Main Table].CN_PN) Is Null) AND (([JFWorkflow Main
Table].[Assigned Resource]) Like [Forms]![Search]![Assigned Resource] & "*"
Or ([JFWorkflow Main Table].[Assigned Resource]) Is Null));
But if you search my Assigned Resource you will also get everything not
Assigned
Thanks
example to see all the contracts for a specific Assigned Resource you can
just type in the Assigned Resourse and click search. However, my problem is
when one of the search fields is left blank. I do not get the results I
need. I want the query to use the information entered into the form but alow
anything in the fields that are left null.
I have 20 feilds you can search by but I only included two because of length.
My first try:
SELECT [JFWorkflow Main Table].CN_PN, [JFWorkflow Main Table].[Assigned
Resource]
FROM [JFWorkflow Main Table]
WHERE ((([JFWorkflow Main
Table].CN_PN)=If([Forms]![Search]![CN_PN]<>"",([JFWorkflow Main
Table].[CN_PN]) Like [Forms]![Search]![CN_PN] & "*","")) AND (([JFWorkflow
Main Table].[Assigned Resource])=If([Forms]![Search]![Assigned
Resource]<>"",([JFWorkflow Main Table].[Assigned Resource]) Like
[Forms]![Search]![Assigned Resource] & "*","")));
But I do not get any results if a field is left blank. I assume I need
something else in the "false" field of the "if" statement.
Here is my other try:
SELECT [JFWorkflow Main Table].CN_PN, [JFWorkflow Main Table].[Assigned
Resource]
FROM [JFWorkflow Main Table]
WHERE ((([JFWorkflow Main Table].CN_PN) Like [Forms]![Search]![CN_PN] & "*"
Or ([JFWorkflow Main Table].CN_PN) Is Null) AND (([JFWorkflow Main
Table].[Assigned Resource]) Like [Forms]![Search]![Assigned Resource] & "*"
Or ([JFWorkflow Main Table].[Assigned Resource]) Is Null));
But if you search my Assigned Resource you will also get everything not
Assigned
Thanks