473,394 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Form and query

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
6 1367
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
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
"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
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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Harvey | last post by:
Hi, I try to write an asp query form that lets client search any text-string and display all pages in my web server that contain the text. I have IIS 6.0 on a server 2003. The MSDN site says...
3
by: Steve | last post by:
Form FrmRestock's recordsource is QryFrmRestock. The TransactionDate field's criteria is set ats: Forms!FrmRestock!LastXDays. LastXDays on the form is a combobox where the selections are 30, 60...
2
by: neptune | last post by:
I built a form to access a query with a 2 field primary key. It should use 2 controls to find the unique record and display the other field values on the form. In the criteria section of the...
25
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
4
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the...
0
by: jphelan | last post by:
I have a subform that works fine until you import it into a new database when it crashes if you try to open it in either disign or form view. The form, "Attendees_Subform" in my application was...
2
by: Robert | last post by:
I am trying to give the user dynamic search capabilities to select almost any record in the database from criteria they select. Everything seems to work except when I open the display form to...
26
by: Jerim79 | last post by:
I need to create a form that takes a number that the user enters, and duplicates a question the number of times the user entered. For instance, if the customer enters 5 on the first page, when...
8
by: hoofbeats95 | last post by:
I don't think this should be this complicated, but I can't figure it out. I've worked with C# for several years now, but in a web environment, not with windows form. I have a form with a query...
8
by: tess | last post by:
I have: table 1 - tblLeadInfo which includes a salesman ID field table 2 - tbllkpSalesman with all zips in the state and a Salesman assigned to that area. I have a form based on table #1 When...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.