spalmateer
Registered User.
- Local time
- Today, 22:50
- Joined
- Dec 5, 2000
- Messages
- 46
Hi,
I just found out that the search form we've been using for the last two years was fundamentally flawed- only showing records that were not null in certain fields. I guess there is ALOT of value in extensively testing before deploying!! Anyway- I have a query that receives its criteria from a value in a textbox on a form. Here is the formula I'm using:
Like IIf(IsNull([Forms]![frmSearch]![txtLastName]),"*",[Forms]![frmSearch]![txtLastName] & "*")
What I would like it to do is if the value on the textbox is null, then I don't want any value in the criteria, therefore it would show all records, null or not. I've come to find out the problem is with the "LIKE" expression. If there is nothing in the textbox, then the expression returns Like * and then it only shows records that contain a value. So I tried the following formula to try to eliminate the like unless there is a value in the textbox:
=IIf(IsNull([Forms]![frmSearch]![txtLastName]),"","Like " & [Forms]![frmSearch]![txtLastName] & "*")
This didn't work either. Is there a way I can pull a value from a textbox for the criteria of a query but only if there is a value in the textbox. If there isn't then it should have nothing in the criteria. "" doesn't seem to work. Any help with this would be much appreciated!! Thanks!
Scott
[This message has been edited by spalmateer (edited 04-21-2002).]
I just found out that the search form we've been using for the last two years was fundamentally flawed- only showing records that were not null in certain fields. I guess there is ALOT of value in extensively testing before deploying!! Anyway- I have a query that receives its criteria from a value in a textbox on a form. Here is the formula I'm using:
Like IIf(IsNull([Forms]![frmSearch]![txtLastName]),"*",[Forms]![frmSearch]![txtLastName] & "*")
What I would like it to do is if the value on the textbox is null, then I don't want any value in the criteria, therefore it would show all records, null or not. I've come to find out the problem is with the "LIKE" expression. If there is nothing in the textbox, then the expression returns Like * and then it only shows records that contain a value. So I tried the following formula to try to eliminate the like unless there is a value in the textbox:
=IIf(IsNull([Forms]![frmSearch]![txtLastName]),"","Like " & [Forms]![frmSearch]![txtLastName] & "*")
This didn't work either. Is there a way I can pull a value from a textbox for the criteria of a query but only if there is a value in the textbox. If there isn't then it should have nothing in the criteria. "" doesn't seem to work. Any help with this would be much appreciated!! Thanks!
Scott
[This message has been edited by spalmateer (edited 04-21-2002).]