Like query from text box on form.

  • Thread starter Thread starter Francis
  • Start date Start date
F

Francis

I has been some time since I have used access and I am
having difficulty doing what should be a simple operation.

I have a form with two text boxes on it.

Contact Name and Company Name

I want to be able to query one or the other or both using
a like query, so the operator only has to enter part of
the contact or company name.

So far I can only get it to work with the entire string of
the field and only one field at a time. If I leave one of
text boxes blank I want to return all the records like the
string of the other text box.

Any help would be greatly appreciated.
Regards
Francis
 
Francis,

Try putting the equivalent of this in the criteria of each of the fields...
Like "*" & Nz([Forms]![FormName]![TextboxName],"*") & "*"
 
Steve,
Can't this be done just as easily without the Nz()?

--
Duane Hookom
MS Access MVP


Steve Schapel said:
Francis,

Try putting the equivalent of this in the criteria of each of the fields...
Like "*" & Nz([Forms]![FormName]![TextboxName],"*") & "*"

--
Steve Schapel, Microsoft Access MVP

I has been some time since I have used access and I am
having difficulty doing what should be a simple operation.

I have a form with two text boxes on it.

Contact Name and Company Name

I want to be able to query one or the other or both using
a like query, so the operator only has to enter part of
the contact or company name.

So far I can only get it to work with the entire string of
the field and only one field at a time. If I leave one of
text boxes blank I want to return all the records like the
string of the other text box.

Any help would be greatly appreciated.
Regards
Francis
 
Duane,

It's like compost on a garden... you just can't have too many *s! <g>

Seriously, I have absolutely no idea why I did it that way. Thanks for
the heads-up :-)
 
Back
Top