Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

? writing a Multiple query with a text box as the controller

Status
Not open for further replies.

njpaco

Technical User
Nov 27, 2001
5
US
can anyone please give me an example of how to write a multiple query. ok this is what I'm trying to do, for example an address book has three fields( name, address, & number). Once I open the form these fields are textboxes on a form. I want to be able to write in anyone of these fields and click on one (command button) which will search every field.

First it will search if a textbox contains information if it does it will run preform the query if not will continue to the next textbox to search for information, ex. I only had the person name it will use the person name from the textbox and run a query then it go to the next textbox and check if there is any inform there, since there is none because we only have the person's name it will skip to the next textbox which will be address, it will do the same checks for any inform if not proceeds to end the query since there is only 3 fields of search.

I've tried writing one but to no avail. I know i need to use null and isnull and if else statements. my other problem is to setting the query to use the textbox as the control source. If any one has an example I would appreicate. If not even a guideline for me to try to follow would help. thanks in advance
 
Try something like this for making your query

querystring
querystring = ""
if text1 & &quot;&quot; <> &quot;&quot; then
querystring = &quot;Where name like '&quot; & text1 & &quot;%'&quot;
end if

if text2 & &quot;&quot; <> &quot;&quot; then
if querystring <> &quot;&quot; then
querystring = querystring & &quot; And address like '&quot; & text2 & &quot;%'&quot;
else
querystring = &quot;Where address like '&quot; & text2 & &quot;%'&quot;
end if

if text3 & &quot;&quot; <> &quot;&quot; then
if querystring <> &quot;&quot; then
querystring = querystring & &quot; And number like '&quot; & text3 & &quot;%'&quot;
else
querystring = &quot;Where number like '&quot; & text3 & &quot;%'&quot;
end if


Hope this is of some help to you.

Mark

The key to immortality is to make a big impression in this life!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top