473,396 Members | 2,154 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,396 software developers and data experts.

Query by Form

5
Hi.

(Access 2002 - Windows XP Pro)

I have a select query called "Find Suppliers". One of its fields is "supplierName" which is derived from a linked "Suppliers" table.

I have a form called "Select Suppliers" which has a combobox which lists all the suppliers names and is derived from a small select query.

I have a second form called "Show Suppliers" which I want to use to show all the suppliers extracted from the "Find Suppliers" query based on the "Select Suppliers " form with the combobox.

I've tried various combinations of filtering in the query as well as the "Show Suppliers" form and getting in an awful muddle on who is passing what to whom.

My second form above shows all the suppliers irrespective on what I ask. The "Find Suppliers" query insists on asking for the search parameters.

Could someone help to point me in the right direction, please? Thanks

Roderick
Nov 17 '07 #1
4 1305
puppydogbuddy
1,923 Expert 1GB
You did not post your queries, so I can't into any specifics on them. What I can tell you is that where you are passing parameters between two forms, either, both forms have to be open ..... or the parameters passed from form1 have to be captured in a global variable before form1 closed. The parameter can then be passed from the global variable to form2's combo box when form2 opens.
Nov 17 '07 #2
sierra7
446 Expert 256MB
If the combo box in your "Find Suppliers" form is called Combo1 the query behind it should include a key field such as [SupplierID]. If this is the first column in the query, your After_Update event on Combo1 should have something like:
Expand|Select|Wrap|Line Numbers
  1. Dim strCriteria as String
  2.  
  3. strCriteria = "[SupplierID] =" & Me.Combo1.Column(0)
  4.  
  5. DoCmd.OpenForm "Show Suppliers", , , strCriteria
  6.  
  7. DoCmd.Close acForm, "Find Suppliers"
This will open the "Show Suppliers" form and display only data relating to the selected supplier. This assumes that [SupplierID] is a key field (Long integer) that uniquely identifies a supplier and is also included in the select query of "Show Suppliers". You will know that in Access VBA you can have multiple colums in the query behind a combo box, so the second column (refered to as Column(1) !!) could display Supplier Name by hiding the first column by setting its width to zero.

If you must use [SupplierName] it will be a string field so the syntax for defining strCriteria must include quotes e.g.
Expand|Select|Wrap|Line Numbers
  1. strCriteria = "[SupplierName] = ' " & Me.Combo1.Column(0) & " ' "
Instead of bothering with two forms you could embed the combo box in the Header section of "Show Suppliers". Access seems to let a form re-open itself with a new criteria. This way you don't have to keep going back to reopen your "Find Suppliers" form to query another supplier.

Another variation with the combo in the header of "Show Suppliers" is to use the Set Filter technique. Here the after update event would look something like;

Expand|Select|Wrap|Line Numbers
  1. Dim strCriteria as String
  2.  
  3. strCriteria = "[SupplierID] =" & Me.Combo1.Column(0)
  4.  
  5. Me.Filter = strCriteria
  6. Me.FilterOn =True

I hope that helps
Nov 18 '07 #3
roryok
5
Thanks to you both for the replies. They were extremely useful.

Fiddled around with Sierra7's code and got what was required. Client wanted separate forms so kept it that way.

Thanks again.

I've got a further query about filtering but will make a new post.
Nov 19 '07 #4
sierra7
446 Expert 256MB
Glad to have been of some help.

However, just for the record, the terms 'Filter by Form' and probably 'Query by Form' have a special meaning in Access where you use the little 'filter-funnel' buttons in the top menu.

These give extremely flexible filtering by any combination of fields on the form.

I admit to shying away from them in my early Access developments for a variety of reasons but am starting to look at them again as users are 'more computer literate' than say 5 years ago.
Nov 21 '07 #5

Sign in to post your reply or Sign up for a free account.

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: MX1 | last post by:
I have a query written in MS Access that has a few calculated fields. Is it possible to refer to that query in a form field. I'd like the form field to show the sum of one of the columns from the...
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...
1
by: Nicolae Fieraru | last post by:
Hi All, I want to find if there is a different way than the way I am working now. Lets say I have a table, tblCustomers containing address details. I want a report with all the customers from...
6
by: Brian | last post by:
Hello, Basically, I'm running a query on a form's activation, and I'd like to have the results of the query be placed into other fields on the same form automatically. Does anybody know how...
13
by: Lee | last post by:
Hello All, First of all I would like to say thank you for all of the help I have received here. I have been teaching myself Access for about 4 years now and I've always been able to find a...
3
by: rhobson2 | last post by:
Hello, I wrote a database applicaiton using Access XP (2002) and everything has been working good for the client until they purchased a couple of new computers with Access 2003. The meetings...
1
by: bgreenspan | last post by:
Hi Everyone, I'm back for some more expert help. Here's what I am doing and what I tried. My database has entries with Contract Names and Expiry Dates, among other fields. I have a form...
3
by: pbd22 | last post by:
Hi. I need some help with structuring my query strings. I have a form with a search bar and some links. Each link is a search type (such as "community"). The HREF for the link's anchor looks...
2
by: lindabaldwin | last post by:
Hello everyone, I am fairly new to VBA. I have a worksheet in Excel, named "Data Sheet" from which I am trying to query data. This worksheet contains the following data: unit (column A), date...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.