473,616 Members | 2,800 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Auto. display of table record in form

135 New Member
Hello

I have a table PRODUCT NAMES with fields PRODUCTNAME and COMMODITY, another table called COMMODITY NAMES with the only field COMMODITIES (containing a list of 7 different commodities), and a form called ENGINEERING with TWO separate combo boxes (PRODUCTNAME and COMMODITY) where the user has to select a product from the already filled in PRODUCT NAMES table which are displayed as "options".

I need the COMMODITY combo box in the form to automatically display the value of its related PRODUCTNAME in the PRODUCT NAMES table. And if that specific product doesnt have an already specified one, that the user could select the commodity from the combo box list (which "row source" is the COMMODITIES field on the COMMODITY NAMES table).

How can i do this? or

Is it possible or is it better to delete the COMMODITY NAMES table out of the question so that initially EVERY product has to have their corresponding commodity filled in?

Thanks,
Gilberto
Sep 13 '07 #1
11 1830
Scott Price
1,384 Recognized Expert Top Contributor
What is the nature of the relationship between Commodities and Products?

You are looking for One To One, One To Many or Many to Many... Ask yourself questions like can one commodity have more than one product? Can one product have more than one commodity?

If one product will only have one commodity and one commodity will only be associated with one product then you have a one to one relationship and it will be all right to combine the two tables.

If one product can have more than one commodity, or one commodity can be related to more than one product (which I suspect is the case) you have a one to many and therefore need the second table.

If one product can be related to more than one commodity AND one commodity can be related to more than one product you have a many to many relationship and therefore need a third, linking, table.

Now then, on your commodities table, normal practice is to place a second field named CommodityID and use this field as the primary key, giving it an autonumber value. In your combo box you reference this in the row source like this: SELECT CommodityID, Commodity From Commodities.

Create a query that pulls the values you want to show on the form, then bind your various controls to update the fields being passed by the query.

Any questions, don't hesitate to ask!

Regards,
Scott
Sep 15 '07 #2
Gilberto
135 New Member
What is the nature of the relationship between Commodities and Products?

You are looking for One To One, One To Many or Many to Many... Ask yourself questions like can one commodity have more than one product? Can one product have more than one commodity?

If one product will only have one commodity and one commodity will only be associated with one product then you have a one to one relationship and it will be all right to combine the two tables.

If one product can have more than one commodity, or one commodity can be related to more than one product (which I suspect is the case) you have a one to many and therefore need the second table.

If one product can be related to more than one commodity AND one commodity can be related to more than one product you have a many to many relationship and therefore need a third, linking, table.

Now then, on your commodities table, normal practice is to place a second field named CommodityID and use this field as the primary key, giving it an autonumber value. In your combo box you reference this in the row source like this: SELECT CommodityID, Commodity From Commodities.

Create a query that pulls the values you want to show on the form, then bind your various controls to update the fields being passed by the query.

Any questions, don't hesitate to ask!

Regards,
Scott

Scott, thank you for your reply.

As you supposed 1 commodity can be asigned to more than one product but a product can have ONLY one commodity. I already have the two tables related (COMMODITIES and ENGINEERING) and on my COMMODITY combo box (in the ENGINEERING FORM) i already have:

Expand|Select|Wrap|Line Numbers
  1. "SELECT [Commodity Name].CommodityId, [Commodity Name].Commodity FROM [Commodity Name] ORDER BY [Commodity];"
which works very good displaying the list of the 11 different types of commodities.

I just created a one to many relationship between tables COMMODITIES and PRODUCTS (linking COMMODITY ID field from both tables, which im not sure its correct....). By now, SOME products (in the PRODUCTS table) ALREADY have the commodity specified under the field name (COMMODITY on the PRODUCTS table) and i want THIS already specified commodity (from COMMODITY in table PRODUCTS) to be automatically displayed in the combobox.

To make it a bit clear, i have:

PRODUCTS ("catalog" table) with fields:
ProductNameID
CommodityID
ProductName
Commodity

COMMODITIES (table) with:
CommodityID
Commodity

ENGINEERING (table AND FORM) whith:
ProductName
Commodity

In this last table the user selects from the combo box PRODUCTS (which is linked with a whole catalog of product names from the table PRODUCTS) a product and from the combo box COMMODITY, its commodity.

Thanks,
Gil
Sep 17 '07 #3
Scott Price
1,384 Recognized Expert Top Contributor
Have you tried something like this?

In the RowSource for your combo box Products:
Expand|Select|Wrap|Line Numbers
  1. SELECT ProductID, Product FROM tblProducts WHERE tblProducts.CommodityID = Me!cboCommodity
You'll have to change the names I used here to reflect the names you are using for the respective objects.

Regards,
Scott
Sep 17 '07 #4
Gilberto
135 New Member
Have you tried something like this?

In the RowSource for your combo box Products:
Expand|Select|Wrap|Line Numbers
  1. SELECT ProductID, Product FROM tblProducts WHERE tblProducts.CommodityID = Me!cboCommodity
You'll have to change the names I used here to reflect the names you are using for the respective objects.

Regards,
Scott
Thanks for the reply Scott. I just dont understand why i should use this with the PRODUCTS combo box instead of the COMMODITY one, which is what i want to automatically display ONCE you select the product (as each product already belong to a commodity in the products table). I tried to adapt what you gave me with no luck, at the same time i cant see how this (your code) could ALSO allow you to select from the different commodity options from the combo box, in case the product didnt have one specified already.

Thanks again,
Gilberto
Sep 19 '07 #5
Scott Price
1,384 Recognized Expert Top Contributor
The row source code i gave you was assuming that you want to be able to select from the Commodities combo box a commodity, say Windows 2000 Computer Systems, and have the Products combo box filter to only those products that match the chosen commodity.

Obviously I didn't understand what you are trying to accomplish. Leaving aside the technical aspect for the moment, just tell me in plain language what you want this combo box setup to do.

Regards,
Scott
Sep 19 '07 #6
Gilberto
135 New Member
The row source code i gave you was assuming that you want to be able to select from the Commodities combo box a commodity, say Windows 2000 Computer Systems, and have the Products combo box filter to only those products that match the chosen commodity.

Obviously I didn't understand what you are trying to accomplish. Leaving aside the technical aspect for the moment, just tell me in plain language what you want this combo box setup to do.

Regards,
Scott
OK...

Actually i think you are right and this could be another approach i could take.

However in plain english i want this second combo box to DISPLAY the selected product current "pre-difined" commodity or to let the user select from the 11 different commodity possibilities. Thats all.

Thanks again for your time and effort.
Sep 19 '07 #7
Scott Price
1,384 Recognized Expert Top Contributor
OK...

Actually i think you are right and this could be another approach i could take.

However in plain english i want this second combo box to DISPLAY the selected product current "pre-difined" commodity or to let the user select from the 11 different commodity possibilities. Thats all.

Thanks again for your time and effort.
Ok, so given one combo box that chooses commodities, you want the second combo box to display products that relate to that chosen commodity... The row source i gave you should do that as is. If you are just looking to display, try changing the products combo box to a list box (right click on combo box in design view, choose Change To>ListBox, you can change it back this way also if you don't like it :-) It takes up a bit more form real estate, but will give a better view of the related products.

Now the second part after "or" is where I'm not understanding yet :-) Are you wanting to be able to select a product in the combo box, and within the same combo box be able to change it's related commodity? If this is the case, I don't think that's possible. That would be something like a multifunction combo, which I'm sure Access (at least 2003 and earlier) doesn't provide.

To accomplish this, you will need to display the Product details in something like a continuous form or subform on your main form. In this view, each product will be listed with it's attributes (Price, Commodity, ManufactureDate , ExpiryDate, etc.) In the corresponding controls you will be able to change whatever information you wish to change about the selected product.

Regards,
Scott
Sep 19 '07 #8
Gilberto
135 New Member
Ok, so given one combo box that chooses commodities, you want the second combo box to display products that relate to that chosen commodity... The row source i gave you should do that as is. If you are just looking to display, try changing the products combo box to a list box (right click on combo box in design view, choose Change To>ListBox, you can change it back this way also if you don't like it :-) It takes up a bit more form real estate, but will give a better view of the related products.

Now the second part after "or" is where I'm not understanding yet :-) Are you wanting to be able to select a product in the combo box, and within the same combo box be able to change it's related commodity? If this is the case, I don't think that's possible. That would be something like a multifunction combo, which I'm sure Access (at least 2003 and earlier) doesn't provide.

To accomplish this, you will need to display the Product details in something like a continuous form or subform on your main form. In this view, each product will be listed with it's attributes (Price, Commodity, ManufactureDate , ExpiryDate, etc.) In the corresponding controls you will be able to change whatever information you wish to change about the selected product.

Regards,
Scott
Sorry Scott i think im still not being very clear.

The form has TWO combo boxes, one where the user selects the product (from a catalog) and another where the user "classifies " that selected product with one commodity. All the selected and classified products go to a separate table than from the catalog.

so, for example:

The user clicks on the PRODUCTS combo and a list of product names appear (from the catalog table), he selects one product.
Then on another combo he clicks to see the list of commodities and selects the commodity that corresponds to that selected product.

PRODUCT ---driver head rest cushion---- COMMODITY ---Head Rest---

So far it works ok, however SOME of this products, have already a commodity record on the catalog table. So having to select the commodity is just double work.

So for THIS products that have already a specified commodity i want the commodity box to display it, otherwise the user just can select it from the list.

So it CANT work the way you are suggesting (As in FIRST selecting the commodity and THEN selecting each product)

Hope its better now.
Gil
Sep 19 '07 #9
Scott Price
1,384 Recognized Expert Top Contributor
Sorry Scott i think im still not being very clear.

The form has TWO combo boxes, one where the user selects the product (from a catalog) and another where the user "classifies " that selected product with one commodity. All the selected and classified products go to a separate table than from the catalog.

so, for example:

The user clicks on the PRODUCTS combo and a list of product names appear (from the catalog table), he selects one product.
Then on another combo he clicks to see the list of commodities and selects the commodity that corresponds to that selected product.

PRODUCT ---driver head rest cushion---- COMMODITY ---Head Rest---

So far it works ok, however SOME of this products, have already a commodity record on the catalog table. So having to select the commodity is just double work.

So for THIS products that have already a specified commodity i want the commodity box to display it, otherwise the user just can select it from the list.

So it CANT work the way you are suggesting (As in FIRST selecting the commodity and THEN selecting each product)

Hope its better now.
Gil
The light is beginning to dawn :-) So how does leaving the Product combo unbound, and then binding the Commodity combo to it's field in the Product(Catalog ) table work?

Regards,
Scott
Sep 19 '07 #10

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

Similar topics

2
3768
by: Irwinsp | last post by:
Hi All, I have a form with an auto number field displayed. The field looks great except when the user is entering a new record. The field then has the text "auto number" in it. Is there a better way to display this field. I thought the number assigned to this record should be displayed while the user is entering the rest of the form data. Thanks, Paula
1
5273
by: mikeybe | last post by:
Making a very simple library circulation database for a school project. I have a Patron Information table(patronID, first name, last name, phone) , an item information table (bookID, book title, authorfirst, author last) and a circulation file (ID, bookID, patronID, checoutdate, checkindate). Circulation file is linked to others in a one to many fashion so that I can have the same book checked out time after time.
4
10640
by: the hotshot | last post by:
hello, this seems to be a hard question so far and noone has been able to help with this. is it possible to have access start an autonumber with a prefix according to the year when the data is entered. for example, if i entered something in 2004, i would like the number to bigin with 2004003, 2004004, 2004005... and same for 2005001, 2005002...? much and great appreciation for suggestions. thank you,
3
2585
by: Chris | last post by:
Before I started to create table, etc to track unique form field record number assigments I thought I'd check to see if there is now a better way to do this in .NET. I have a parent form (table) and children form (table). Relationship equals one to many. I'd like to auto number the fields accordingly and traditionaly I assign a unique number based on a table value that I retrieve + 1. i.e. Parent record field value = 1 Children record...
1
3285
by: DSR | last post by:
Can anyone tell me how to do this? I have a table (TableBuildings) that I want to auto create data to its sub datasheet (TableDaysOfWeek) whenever a new record is added to the parent table (one to many). The data that I want to auto create is each day of the week (Mon - 1st record, Tue - 2nd record, Wed 3rd record ... etc) each as its own record. Each of these records will be unique based on an auto number ID field in that table. Therefore...
6
2735
by: AA Arens | last post by:
Hi, I have a database with 2 main forms. Contacts and companies. I share the base with two others via LAN. On the companies form I have buttons to navigate throught the records (>400). We are mostly handling let say 5 companies. Every time I have to navigate or choose the find record button to get the right company. I am looking fo a feature to have listed in a combo list the last 5 visited records ("recently visited records").
2
5531
by: john | last post by:
Is it true that if I split my access database in backend and frontend and I implement custom auto increment for the ID fields, that my database is ready to be used in a multi-user environment? I found a zillion messages about auto increment and read some of them but it's confusing. Can someone point me to a simple custom auto increment example that I can download? Thank you, john
3
11992
by: S.Dickson | last post by:
I had an access database that i use as an ordering system. I have a form for entering customer details. When i add a new customer on the form the customer number is an auto number that appears when i type in the details. I have just moved over to mysql server with access as the front end. I have setup the sql tables with the customer number as autonumber. When i go into the form and add a new customer it does not generate the
1
2351
by: Jim | last post by:
I have a new database in which I have a form where in one field I type a letter A, B, C or D and the field next to it autofills (auto lookups) with a description associated with the specific letter. If I edit the description for one record, it edits the same for all records in which I've applied the same autofill (auto lookup). I'm set up where the letters come from a lookup combo box (limit to list "Yes") and the record source for the...
5
17674
by: joshua.nicholes | last post by:
I have an access database that consists of two tables.A data collection table and a species list table. The data collection table has about 1500 records in it and the species list has about 600. The species list has 7 fields the first is a four digit unique identifier (species) it is set as the primary key. I have created a relationship to the data collection table which also has a species field (4 digit id). In my form I have the species...
0
8145
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
8592
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8294
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7118
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6097
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
4060
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
4140
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2576
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
0
1439
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.