473,378 Members | 1,527 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,378 software developers and data experts.

How can I extract other field values on a table knowing the value of one field

I have two tables:

The first table is called:
Products
it has the following fields
ProdName
ProdId
ProdType
ProdTaxes

The second table is called:
ProductInput
with the following fields
ProductId
Quantity
Price
TaxPercentage
...and others...

I have made a form based on table 'ProductInput'
I use a combo to get the ProdId (Products table) by means of
ProdName (Products table) and I put it in ProductId (ProductInput table)

My question is:
How can I get the corresponding record in the table 'Products' using
ProductId (ProductInput table), to extract the other fields (like ProdType
and ProdTaxes -Product table-) and put them in the fields TaxPercentage,
Price, etc of ProductInput table.
Nov 22 '06 #1
16 1899
NeoPa
32,556 Expert Mod 16PB
Try using this SQL (or something derived therefrom) as the basis for your form rather than a simple link to the table :
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM [Products] LEFT JOIN [ProductInput] ON Products.ProdId = ProductInput.ProductId
Nov 22 '06 #2
I am sorry but I am very new at this
and I do not understand the idea
Where should I put this code?
And could I get a thorough explanation of what it does?

Thanks a lot!
Nov 22 '06 #3
NeoPa
32,556 Expert Mod 16PB
Edit the form in Design View.
Look at properties of the form.
Near the top there is a Record Source property.
Select this and enter the SQL from previous post or your modified version.
Press F1 for help on the Record Source property.

This should get you going.
Nov 22 '06 #4
At the moment it is not working!
It says that the query does not exist!
Maybe I have not spelt it correctly!

Why the asterisc?

Thanks for your time
Nov 22 '06 #5
Excuse me!
I had spelt it badly!
Now it gives no error

But I do not know how to go on

What do I have to write in Control Source of the button TaxPercentage
to get the value of ProdTaxes of the table Products?

This is very confusing, I'm sorry!
Thanks in advance
Nov 22 '06 #6
NeoPa
32,556 Expert Mod 16PB
The asterisk (*) means to return all fields available.
In the Control Source property of your TaxPercentage control (TextBox) drop down the list and you should see the field you need in the list.
Nov 22 '06 #7
It surely works now!!
I am obliged
Thank you very much
I must check everything more thoroughly and try to understand
what I have done

So If I want to get other values from other tables I just should
add the tables in this query, I suppose!
I'll give it a try

I'll keep in touch for further help!
Bye
Nov 22 '06 #8
NeoPa
32,556 Expert Mod 16PB
...and to help you with the SQL you can design the query in Access design view then either :
1. Get the SQL from the query (SQL View) and paste it in or
2. Just use the Query name instead of the SQL in the RecordSource of the form.
Nov 22 '06 #9
I have taken a look at the record source
and I have pressed the 3 dotted button to see
how the query has been done but
there is nothing written there.

Is this normal?

So if I must create the query from Access in design view
What must I write?

I do not understand much the LEFT JOIN and ON commands
even though I have read an SQL Tutorial about it.

Thanks!
Nov 23 '06 #10
OK!
Forget the last post
I have worked a little with it and now I think that I understand
I have added another relation to the query and now
I also can get values from this new table

It seems to work but I'm sure it will come up with other problems
because I have to add many other things

It's been a great help, thanks indeed!

Another question!!!!
I had posted other messages but I think they're not
much understandable, so is there a way to delete them?

Bye
Nov 23 '06 #11
NeoPa
32,556 Expert Mod 16PB
Identify anything you would like deleted (Post #) and I will do it for you (Only moderators and admins can do that).
Nov 23 '06 #12
I think I have another problem here!

Now, I get the values from another table perfectly well (Products)
and I see these values in the form
but they are not present in the form's table! (ProductInput)

I set Control source to the field of the other table (Products) from where I
want the value taken
but even though the value can be seen in the form,
it is not inserted in the table (ProductInput)

I do not know wether this is clear enough!
Thanks
Nov 24 '06 #13
NeoPa
32,556 Expert Mod 16PB
What are you using as the RecordSource of the Form?
(Any Filter info would be useful too).
Nov 24 '06 #14
In the record source of the form I use the query in SQL you gave me.
I have added other tables but it seems to work perfectly

But now I am aware that I can get the 'ProdTaxes' from 'Products' table
and I can see it in the 'ProductInput' form
but I would like to keep it in 'TaxPercentage' field of 'ProductInput' table

Another example:
Imagine I have a table with three fields:
Quantity
Price
Total
If I set the control for the Total field (control source =[Quantity]*[Price]
then when I'm in the form I see the result but It is not entered in the
table

Maybe confusing!
Thanks
Nov 24 '06 #15
NeoPa
32,556 Expert Mod 16PB
In the record source of the form I use the query in SQL you gave me.
I have added other tables but it seems to work perfectly

But now I am aware that I can get the 'ProdTaxes' from 'Products' table
and I can see it in the 'ProductInput' form
but I would like to keep it in 'TaxPercentage' field of 'ProductInput' table

Another example:
Imagine I have a table with three fields:
Quantity
Price
Total
If I set the control for the Total field (control source =[Quantity]*[Price]
then when I'm in the form I see the result but It is not entered in the
table

Maybe confusing!
Thanks
So, to avoid scrolling up and down too much, here is the code again.
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM [Products] LEFT JOIN [ProductInput] 
  3. ON Products.ProdId = ProductInput.ProductId
And to show the table layouts again for the same reason :
Expand|Select|Wrap|Line Numbers
  1. Products
  2.     ProdName
  3. PK    ProdId
  4.     ProdType
  5.     ProdTaxes
  6.  
  7. ProductInput
  8. FK    ProductId
  9.     Quantity
  10.     Price
  11.     TaxPercentage
  12. ...and others...
For Referential Integrity it is not advised (No - it's advised NOT) to duplicate data.
Duplication of data means that there is an extra (unnecessary) burden to synchronise this data.
So, you DON'T want to store Products.ProdTaxes and ProductInput.TaxPercentage as the same value. Decide where the data should reside (is it static for a product or does it change across Inputs?), and leave it only there.
This is equally true of a Total field within a single record. Not a good idea to store, but fine to show on a form.

HTH.
Nov 24 '06 #16
The Total field was just an example!
I do not have to include it in the table because everytime
I may need it, all I have to do is re-calculate again!

The problem is:
Products.ProdTaxes could be equal to 18%

So all the products that have this percentage will be calculated
when I make the Invoice with the same value
I do not include the 18% in the ProductInput table because as
you say I can calculate it everytime is needed

But after a year has passed, the percentage could change.
Let's see the taxes could increment to 19.5%

I must change the percentage value (ProdTaxes) in order that the new
Invoices are calculated accordingly

I am afraid the old Invoices will also change the value to the new
percentage and this would be a fatal error

I hope you understand the problem!
Thanks!
Nov 24 '06 #17

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

Similar topics

9
by: jason | last post by:
Access 2000 I need some help interogatting a table and extracting via ASP the final field in a row which has a value. In other words, I have a maximum of 10 fields but, at the user level he may...
2
by: Kai Grossjohann | last post by:
I would like to put a text input field (in the sense of <input type="text">) and an image next to each other, where I know the size in pixels of the image, and I know the total width in em. I...
10
by: MLH | last post by:
I have an A97 table with a Yes/No field named TowJob and a form bound to that table. The TowJob control on the form is bound to the same field. It is an option group with Yes and No bttns valued...
7
by: Aaron Smith | last post by:
How do I set field default values at runtime? Say I want a check box that is bound to a boolean field to default to false for a certain set of criteria, and then true for others? I also need to do...
5
by: rs | last post by:
I have a table with a timestamp field which contains the date and time. ie. 9/13/2004 9:10:00 AM. I would like to split this field into 2 fields, one with just the DATE portion ie 9/13/2004 and...
3
by: zek2005 | last post by:
Hi friends! I have a varchar field in my DB with numeric values separates by spaces. I need to extract the numbers to create an array. Example 1: 1820 1823 1825 --> need to be transform into ...
5
by: klall | last post by:
Hello. I need to extract date information from a memo field entered in the following way: 01/01/2005 - 31/12/2005 01/01/2004 - 31/12/2004 01/01/2003 - 31/12/2003 01/01/1996 - 31/12/1996. The...
12
by: rshepard | last post by:
I'm a bit embarrassed to have to ask for help on this, but I'm not finding the solution in the docs I have here. Data are assembled for writing to a database table. A representative tuple looks...
2
by: beary | last post by:
I have a page with a form which has automatically generated fields, (which come from mysql column names). There could be any number of these fields, and I have no way of knowing exactly what they're...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.