473,796 Members | 2,532 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Filter Code Help

56 New Member
I am not sure how to go about this. Any help would be greatly appreciated. Here is what I am trying to do:

I have a table with records. I want to associate each record with multiple associations.

For Example:

record 1 A-12316 belongs to KI2001, KI4000 and KI9200.
record 2 A-06542 belongs to KI2001 and KI4000.
record 3 A-11523 belongs to KI4000

(I have a total of 33 possible associations)

Now I have a form "FrmOptions " with a command button. I want to be able to Click on the Command Button and perform the following:

OpenForm "FrmParts" (that is linked to a table "TblParts" with all the part records like A-12316),

Next, Filter the form by Association. In otherwords, Filter the "FrmParts" Form by only showing the records that have KI2001 associated to them.
Close the Form "FrmOptions ".

In this example, only the A-12316 and A-06542 would be returned on the form. Also want this form to be read only.

I was thinking of adding 33 fields to each record as part of the record to the Parts Table "TblParts" and populating the fields with the [PRODUCT].

Field titles
PRODUCT 1
PRODUCT 2
Thru
PRODUCT 33

Or would that be to cumbersome? Any Ideas?
Apr 20 '09 #1
9 1773
FishVal
2,653 Recognized Expert Specialist
@Desitech
The only idea you need is an idea about Database Normalization and Table Structures

Kind regards,
Fish.
Apr 20 '09 #2
NeoPa
32,579 Recognized Expert Moderator MVP
It certainly would.

Consider creating an association table containing two fields. One being an FK to the first table you mention (You didn't refer to it by name - unless it was tblParts. Not clear), and the other to a table of the item (I'm expect this is [PRODUCT] table). These two keys together would make up the PK of this association table, and could be linked in quite flexibly, including for the way you need currently.
Apr 20 '09 #3
Desitech
56 New Member
I am pretty new to this. What is a FK and a PK? I am not sure how to have 1 record from the TblParts link to Many records on the new table TblProductAssoc iation.
Apr 20 '09 #4
NeoPa
32,579 Recognized Expert Moderator MVP
@Desitech
Sorry. My bad.

PK = Primary Key.
A unique identifier in a table. Each record has a value which is unique only to that record.

FK = Foreign Key.
A value which is (matches) the PK of a record (generally not itself). This may be in any table.

Consider a table [tblFamily]. It may contain a [Surname] field, which could be a PK for the table. A [tblPerson] table may include a [Surname] field too. In this case though, it would be an FK. Certainly not unique. It could be used as criteria for a WHERE clause though, to select and show all members of a particular family.

Does that make more sense now?
Apr 20 '09 #5
Desitech
56 New Member
So if I have a table entitled tblParts and the Primary Key is on the Part Number field and I make a table entitled tblProduct, (Listing 33 Products in 33 Fields, how does one part record get associated to 1, some, or all of my 33 Products? How do I assign a Foriegn Key? I think I am still pretty lost.
Apr 20 '09 #6
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi. My colleagues Fish and NeoPa have given good advice on how you need to proceed, here. The fundamental problem you have is that in order to design useful tables with a relational database it is absolutely essential to understand the idea of table design and normalisation - which is what the article Fish linked for you in post # 2 is about.

Essentially, relational databases comprise sets of tables, many of which relate to each other in 1-to-many relationships. For example, your product and parts tables link this way, as for each product there can be one or more parts, with no limit on how many. Actually, the 1-many relationship is with product and another table which could be called product-parts. This is a linking table that decomposes what is in reality a many-to-many relationship between product and parts, as for each product there can be many parts, and a part is a component of many products. Many-to-many relationships cannot be implemented directly in a relational database; the many-to-many relationship has to be decomposed into two 1-many relationships, implemented by using a third, linking, table along with the two original tables.

In your product-parts table the primary key of the parts table is carried forward as a foreign key, as is the primary key of the products table itself. There will be many rows in this link table for each of your unique products, as each product comprises many parts.

There is no substitute for understanding the process of normalisation - without it you will not succeed in using a relational database efficiently, if at all.

I'd strongly advise you to read the article referred to, and to work your way through introductory texts on database design. The skills of normalisation of table structures are vital when working with relational databases and simply cannot be skipped.

You will find good examples of 1-many relationships within the Northwind database which ships with Access. It would be useful to you to review how that sample application's tables are built. Even so, you need to do the basic ground work on table design for yourself - there is no substitute or ready-made answer which can help you except by pointing the way.

-Stewart
Apr 20 '09 #7
Desitech
56 New Member
Thanks, I am reading and learning about relationships, and tables right now. I am starting to under stand 1 to many, many to many, and many to 1, relationships. I do apologize for my stupid questions as I am trying to learn access and apply it for work all at the same time, and trying to look for quick answers. I do greatly appreciate everyone's help. I have everything working in my Database from all your input. So now, once I get this last part done I will be finished...unti l another project comes up. I am not a programmer by trade. I am primarily a user trying to be a hack programmer. From going thru the reading, it looks like I have a many to many relationship (many parts to many products) and (many products to many parts). This means I need to use a join table. How does the join table get populated? I have already made the one to many relationships from parts to join table and Products to join table. Do I need to enter every part multiple times if used with multiple products?
Apr 20 '09 #8
Stewart Ross
2,545 Recognized Expert Moderator Specialist
In an Access implementation of a normalised set of tables for the products and parts you would, firstly, set up the tables and implement the relationships between the keys, enforcing relational integrity. Secondly, design queries which provide what is known as a view - behaving like a virtual table - of the underlying data, allowing for user-centred ordering of the rows. Thirdly, design a form-subform combination based on those queries which will allow you to specify a product (on the main form) and select its parts on the subform. The subform's record source will be the product-parts table not the parts one, for the reasons mentioned in my post about decomposing many-to-many relationships.

You will see examples of the use of form-subform structures which populate link tables in the Northwind example database.

Good luck with your project

-Stewart
Apr 20 '09 #9
NeoPa
32,579 Recognized Expert Moderator MVP
Stewart, you always explain things so well.

It makes my post #3 look almost curt. I'm comfortable now that the issue is as clear as it could be.
Apr 21 '09 #10

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

Similar topics

1
7852
by: Robert Neville | last post by:
I would like to add filter functionality to my database whether through the Main form or the subform. This question may be rudimentary, yet I have not less experience with filtering data outside from queries. Let me just add that Allen Browne excellent article about this subject may not apply to this scenario on an elementary level. (Here's the link to the article; Filter a Form on a Field in a Subform -...
0
2246
by: Malcolm Cook | last post by:
I've discovered: Using "File > Print Preview" in a form's datasheet view with a server Filter crashes access after previewing... ....that is, unless ServerFilterByForm has been turned off after applying the filter. See the steps to recreate bug below for details.
4
5140
by: Nhmiller | last post by:
This is directly from Access' Help: "About designing a query When you open a query in Design view, or open a form, report, or datasheet and show the Advanced Filter/Sort window (Advanced Filter/Sort window: A window in which you can create a filter from scratch. You enter criteria expressions in the filter design grid to restrict the records in the open form or datasheet to a subset of records that meet the criteria.), you see the design...
25
6631
by: Johan Bergman | last post by:
Hi, Maybe someone can help me to optimize this C/C++ implementation of a FIR filter (although I realize that I should probably consider an FFT approach instead.) The example below calculates the output signal for 10000 lags from an FIR filter with 10000 taps. The input signal and the filter coefficients is just rubbish in this example. For my intended usage of this filter, it is not necessary to store the state of the filter.
3
1485
by: amir | last post by:
How can I filter again my previous filtered records, I mean when I filter an entire I can filter again and again the filtered data. Many thanks for your help. Amir
3
1848
by: remdeb648 | last post by:
Hi, I am programming a multi-criteria filter in an Access Data Page. I successed to make a simple criteria filter using the code below: (the code is on a button click action) MSODSC.DataPages(0).Filter = "Status= '" & SSTATUS.value & "'" If MSODSC.DataPages(0).IsFilterOn then
1
6061
by: mattscho | last post by:
Re: Filter By From, Apply Filter, Remove Filter Buttons in a Form. -------------------------------------------------------------------------------- Hi All, Trying to create a set of 3 buttons in a form that have the same effect as the "Filter by Form", "Apply Filter" and "Remove Filter" Buttons on the access toolbar. Help would be muchly appreciated. Cheers. In the Click() Event of 3 Command Buttons, place the following code: Code: (...
1
5641
by: Cara Murphy | last post by:
Hi There! Hoping you are able to help me with a filtering scenario: I have created a pop up form (Filter) to filter a report (Open Issues), which currently has a number of combo boxes which apply the filters to the fields in the report. I would like to use this form to filter the report within a date range (Raised Date From and Raised Date To), using unbound text boxes, without having to specify the criteria within the report's...
15
2619
by: Briansmi1116 | last post by:
I created two buttons, that filter my form, They filter in different Fields, and if one is filtered, and the other is not there is a certain amount of record, if they are both pushed, then there is less. This works great, but now I want to filter within what is left in the form, without adding the other records. The code I use to filter using my buttons is: Private Sub filter_closed_Click() If filter_closed.Caption = "Filter Closed"...
1
6801
by: woodey2002 | last post by:
Hi Everyone and many thanks for your time.. I am trying to begin access and a bit of VBA i am enjoying it but I have a annoying problem I just can’t get any where on. My databse mostly includes bits of code for different examples. I have one last thing to finish. I am trying to create a search form that will allow users to select criteria from multiple sources eg ,multi select list boxes , combo boxes. I have a subform showing all the...
0
9527
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10453
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.