By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,377 Members | 1,660 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,377 IT Pros & Developers. It's quick & easy.

Form and query

P: n/a
Hi All

Can anybody tell me how can I build a query which takes a parameter passed
from a form?
The query is:

Select * from tblCustomers
Where CustomerName = Forms!frmCustomers!txtCustomerName

When txtCustomerName is left blank, I want the query to show all the
Customers from the table.

Any help appreciated.

Regards,
Nicolae
Nov 13 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Nicolae, Design a new query using your customer table. Add the field you
want. In the criteria row under CustomerName type in
= Forms!frmCustomers!txtCustomerName Or Is Null
Use this query as the record source of your form.
--
Reggie

----------
"Nicolae Fieraru" <no****@please.cxm> wrote in message
news:40********@duster.adelaide.on.net...
Hi All

Can anybody tell me how can I build a query which takes a parameter passed
from a form?
The query is:

Select * from tblCustomers
Where CustomerName = Forms!frmCustomers!txtCustomerName

When txtCustomerName is left blank, I want the query to show all the
Customers from the table.

Any help appreciated.

Regards,
Nicolae

Nov 13 '05 #2

P: n/a
I found out.
The query has to be like this:

Select * from tblCustomers
Where CustomerName LIKE Forms!frmCustomers!txtCustomerName & "*"

Regards,
Nicolae
"Nicolae Fieraru" <no****@please.cxm> wrote in message
news:40********@duster.adelaide.on.net...
Hi All

Can anybody tell me how can I build a query which takes a parameter passed
from a form?
The query is:

Select * from tblCustomers
Where CustomerName = Forms!frmCustomers!txtCustomerName

When txtCustomerName is left blank, I want the query to show all the
Customers from the table.

Any help appreciated.

Regards,
Nicolae

Nov 13 '05 #3

P: n/a
"Nicolae Fieraru" <no****@please.cxm> wrote in message news:<40********@duster.adelaide.on.net>...
I found out.
The query has to be like this:

Select * from tblCustomers
Where CustomerName LIKE Forms!frmCustomers!txtCustomerName & "*"

Regards,
Nicolae


Very nice. This technique seems to be a cousin to using varX & "" to
cast Null values into empty strings. I have some code to rewrite. Can
you identify the artist that came up with this masterpiece?

James A. Fortune
Nov 13 '05 #4

P: n/a
ja******@oakland.edu (James Fortune) wrote in message news:<a6**************************@posting.google. com>...
"Nicolae Fieraru" <no****@please.cxm> wrote in message news:<40********@duster.adelaide.on.net>...
I found out.
The query has to be like this:

Select * from tblCustomers
Where CustomerName LIKE Forms!frmCustomers!txtCustomerName & "*"

Regards,
Nicolae


Very nice. This technique seems to be a cousin to using varX & "" to
cast Null values into empty strings. I have some code to rewrite. Can
you identify the artist that came up with this masterpiece?

James A. Fortune


Never mind. Trevor Best used this technique in a post I found from
1995 so it's been around for a very long time.

James A. Fortune
Nov 13 '05 #5

P: n/a
James, don't rewrite too soon.

Suppose your Forms!frmCustomers!txtCustomerName ="Fortune"
Suppose there is also a name "FortuneTeller" in the database ;-)

Both records will show up with the select string
I think Reggies answer is what is needed

Arno R

"James Fortune" <ja******@oakland.edu> schreef in bericht
news:a6**************************@posting.google.c om...
"Nicolae Fieraru" <no****@please.cxm> wrote in message news:<40********@duster.adelaide.on.net>...
I found out.
The query has to be like this:

Select * from tblCustomers
Where CustomerName LIKE Forms!frmCustomers!txtCustomerName & "*"

Regards,
Nicolae


Very nice. This technique seems to be a cousin to using varX & "" to
cast Null values into empty strings. I have some code to rewrite. Can
you identify the artist that came up with this masterpiece?

James A. Fortune

Nov 13 '05 #6

P: n/a
"Arno R" <ar****************@tiscali.nl> wrote in message news:<40**********************@dreader2.news.tisca li.nl>...
James, don't rewrite too soon.

Suppose your Forms!frmCustomers!txtCustomerName ="Fortune"
Suppose there is also a name "FortuneTeller" in the database ;-)

Both records will show up with the select string
I think Reggies answer is what is needed

Arno R


Good point. I checked out my search form and verified that they could
put "Fortune*" in the text field if they wanted more to show up and
just "Fortune" if they didn't using the old code.

Thanks,
James A. Fortune

Law of Administration for the State of Iraq for the Transitional
Period:
....
Article 31.
....
(B) A nominee to the National Assembly must fulfill the following
conditions:
....
(5) He shall not have enriched himself in an illegitimate manner at
the expense of the homeland and public finance.
Nov 13 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.