473,490 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
Create 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 1819
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
Gilberto
135 New Member
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
hehehe Yeah im even more confused now hahah. I dont get what you are saying. Both boxes are bound to a table called engineering where the products the user is entering gets recorded, as well as their commodities. For the lists i just used the row source from the product catalog and commodities list.

Thanks again,
Gilberto
Sep 19 '07 #11
Scott Price
1,384 Recognized Expert Top Contributor
hehehe Yeah im even more confused now hahah. I dont get what you are saying. Both boxes are bound to a table called engineering where the products the user is entering gets recorded, as well as their commodities. For the lists i just used the row source from the product catalog and commodities list.

Thanks again,
Gilberto
Thanks for sticking this out even though we're both a little confused!

I usually don't suggest this, but could you email me a copy of your database with just a bare sample of data in it? This will help me see what you are seeing, and maybe will help me to understand better what you are talking about.

Click on my profile and click the send email button to do this.

Regards,
Scott
Sep 19 '07 #12

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

Similar topics

2
3749
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...
1
5255
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,...
4
10618
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...
3
2571
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)...
1
3274
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...
6
2725
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...
2
5495
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...
3
11975
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...
1
2340
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...
5
17658
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....
0
7142
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
7181
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...
1
6847
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
7352
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
5445
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,...
0
4565
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...
0
3078
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...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1383
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 ...

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.