472,333 Members | 1,069 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,333 software developers and data experts.

How to add records using Query

I currently have a form and subform based on two tables; tblGoodsIn and
tblGoodsInDetail. The fields in the underlying tables do not contain any
price information. only foreign key links to product and price tables. I use
combo boxes to select parts and prices. I want the form to calculate totals
as I enter the data so I can check instantly that what I am entering into
the database tallies with the supplier Invoice. .

I tried doing this using two queries as below, but I can add records in
qryGoodsInDetail, but not in qryGoodsIn. Is it because qryGoodsIn is looking
up another query (ieqryGoodsInDetail). Can I do this using queries or should
I use the form to calculate totals.

I have two queries. qryGoodsInDetail. which uses
tblGoodsInDetail
tblProductPrice
tblProductDescription
tblTaxRate

and qryGoodsIn which uses
tblCustomer
tblGoodsIn
qryGoodsInDetail.

Any help appreciated

John
Nov 13 '05 #1
7 9163
Yes, you are right that it is the other query inside your main query that is
preventing you from adding records. Why have you got a table called
"tblProductDescription"? ProductDescription should be a field in
"tblProducts". By the looks of it you have a database that isn't normalised.
If you want to, post you table structure and relationships and we may help
guide you along the correct path.

Jeff
"John" <br****@gofree.indigo.ie> wrote in message
news:d4**********@reader01.news.esat.net...
I currently have a form and subform based on two tables; tblGoodsIn and
tblGoodsInDetail. The fields in the underlying tables do not contain any
price information. only foreign key links to product and price tables. I use combo boxes to select parts and prices. I want the form to calculate totals as I enter the data so I can check instantly that what I am entering into
the database tallies with the supplier Invoice. .

I tried doing this using two queries as below, but I can add records in
qryGoodsInDetail, but not in qryGoodsIn. Is it because qryGoodsIn is looking up another query (ieqryGoodsInDetail). Can I do this using queries or should I use the form to calculate totals.

I have two queries. qryGoodsInDetail. which uses
tblGoodsInDetail
tblProductPrice
tblProductDescription
tblTaxRate

and qryGoodsIn which uses
tblCustomer
tblGoodsIn
qryGoodsInDetail.

Any help appreciated

John

Nov 13 '05 #2

"Jeff Smith" <No****@Not.This.Address> wrote in message
news:d4**********@lust.ihug.co.nz...
Yes, you are right that it is the other query inside your main query that
is
preventing you from adding records. Why have you got a table called
"tblProductDescription"? ProductDescription should be a field in
"tblProducts". By the looks of it you have a database that isn't
normalised.
If you want to, post you table structure and relationships and we may help
guide you along the correct path.

Jeff

Sorry. That should have read tblProducts.
The structure for the relevant tables are

tblTaxRate
pkTaxRateID-------[ tblGoodsInDetail
TaxRate [ pkGoodsInDetailID
TaxDate [ Quantity
[---------fkTaxRateID
tblGoodsIn
tblProductPrices fkGoodsInID-------------pkGoodsInID
pkProductPriceID-------------fkProductPriceID DeliveryDate
UnitPrice
SupplierInvoiceNumber
UnitPriceDate
fkCompanyName
Markup tblProducts
fkPaymentID
fkProductID--------------pkProductID
ProductCode
ProductDescription
QtyPerUnit
tblProductCategory UnitsInStock
pkCategoryID------------f kCategoryID
ProductCategory

There are other tables, but these are the relevant ones.
John
Nov 13 '05 #3
That didn't display right. Here are the relevant tables. The primary and
foreign keys are self explanatory.

tblTaxRate
pkTaxRateID
TaxRate
TaxDate

tblGoodsInDetail
pkGoodsInDetailID
Quantity
fkGoodsInID
fkTaxRateID
fkProductPriceID

tblGoodsIn
pkGoodsInID
DeliveryDate
SupplierInvoiceNumber
fkCustomerID
fkPaymentID

tblCustomers
pkCustomerID
CustomerName
fkAddressID

tblProductPrices
pkProductPriceID
UnitPrice
UnitPriceDate
Markup
fkProductID

tblProducts
pkProductID
ProductCode
ProductDescription
QtyPerUnit
UnitsInStock
f kCategoryID

tblProductCategory
pkCategoryID
ProductCategory

There are other tables, but these are the relevant ones.


John

Nov 13 '05 #4
The table structure looks fine but in tblGoodsInDetail the ProductPriceID
should be stored to capture the price the product was paid for. Having this
linked at table level can cause problems later if someone changes the price.
i.e. Paid $3.50 for a widget on 23 Mar 2002 and then someone decides to
change the price for a widget in the tblProductPrices to $3.75 instead of
adding a new price and date as with your table structure. This will upset
the history because all calculations will show $3.75 although $3.50 was the
price paid for that widget. Storing the price at the time of the transaction
also makes it easier when creating queries. Fewer tables are required in
your query resulting in a query that will more likely to work as you like it
to and be more updatable.

Back to your original problem. There's no need to use a query for your main
form, just use the tblGoodsIn. Use a query for your sub-form based on the
tblGoodsInDetail. To display the total price of the order in the main form,
add a text box to the Form Footer of the sub-form and in its Control Source
type =Sum([ExtendedPrice]) where the [ExtendedPrice] is the name of a
calculated field in the qryGoodInDetail query
ExtendedPrice:(Price*Quantity)+((Price*Quantity)*T axRate). In the main form,
create another unbound text box and in its Control Source reference the text
box control, = [YourSubFormName].[Form]![YourTextBoxName].

Have a look at the Orders form in the sample Northwind database that comes
with Access to help you.

Jeff
"John" <br****@gofree.indigo.ie> wrote in message
news:d4**********@reader01.news.esat.net...
That didn't display right. Here are the relevant tables. The primary and
foreign keys are self explanatory.

tblTaxRate
pkTaxRateID
TaxRate
TaxDate

tblGoodsInDetail
pkGoodsInDetailID
Quantity
fkGoodsInID
fkTaxRateID
fkProductPriceID

tblGoodsIn
pkGoodsInID
DeliveryDate
SupplierInvoiceNumber
fkCustomerID
fkPaymentID

tblCustomers
pkCustomerID
CustomerName
fkAddressID

tblProductPrices
pkProductPriceID
UnitPrice
UnitPriceDate
Markup
fkProductID

tblProducts
pkProductID
ProductCode
ProductDescription
QtyPerUnit
UnitsInStock
f kCategoryID

tblProductCategory
pkCategoryID
ProductCategory

There are other tables, but these are the relevant ones.


John


Nov 13 '05 #5
On Mon, 25 Apr 2005 20:53:18 +1200, "Jeff Smith"
<No****@Not.This.Address> wrote:
The table structure looks fine but in tblGoodsInDetail


While tblGoodSin has mild interest, tblGoodSinDetail might have
significant commercial value. Perhaps posting a few would be good
reading?

John

Nov 13 '05 #6
Never saw it that way, me thinks you have one track mind :).
"isnotreallyme" <is***********@isnotreallyme.com> wrote in message
news:42****************@news.INDIVIDUAL.NET...
On Mon, 25 Apr 2005 20:53:18 +1200, "Jeff Smith"
<No****@Not.This.Address> wrote:
The table structure looks fine but in tblGoodsInDetail


While tblGoodSin has mild interest, tblGoodSinDetail might have
significant commercial value. Perhaps posting a few would be good
reading?

John

Nov 13 '05 #7
"Jeff Smith" <No****@Not.This.Address> wrote in message
news:d4**********@lust.ihug.co.nz...
The table structure looks fine but in tblGoodsInDetail the ProductPriceID
should be stored to capture the price the product was paid for. Having
this
linked at table level can cause problems later if someone changes the
price.
i.e. Paid $3.50 for a widget on 23 Mar 2002 and then someone decides to
change the price for a widget in the tblProductPrices to $3.75 instead of
adding a new price and date as with your table structure. This will upset
the history because all calculations will show $3.75 although $3.50 was
the
price paid for that widget. Storing the price at the time of the
transaction
also makes it easier when creating queries. Fewer tables are required in
your query resulting in a query that will more likely to work as you like
it
to and be more updatable.

Back to your original problem. There's no need to use a query for your
main
form, just use the tblGoodsIn. Use a query for your sub-form based on the
tblGoodsInDetail. To display the total price of the order in the main
form,
add a text box to the Form Footer of the sub-form and in its Control
Source
type =Sum([ExtendedPrice]) where the [ExtendedPrice] is the name of a
calculated field in the qryGoodInDetail query
ExtendedPrice:(Price*Quantity)+((Price*Quantity)*T axRate). In the main
form,
create another unbound text box and in its Control Source reference the
text
box control, = [YourSubFormName].[Form]![YourTextBoxName].

Have a look at the Orders form in the sample Northwind database that comes
with Access to help you.


Thanks Jeff
Your suggestion on the prices makes sense so I'll implement it. But doesn't
that de-normalize the database. I thought the idea was not to duplicate any
data.

Regards

John
Nov 13 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: jsfromynr | last post by:
Hi all, Here is the table and DML statments CREATE TABLE ( , NULL , DEFAULT (1), -- 1 Pending ,2 Approved (20) )
1
by: PMBragg | last post by:
ORINGINAL Post >Thank you in advance. I'm trying to pull all inventory items from December >of the previous year back to 4 years for my...
2
by: ms | last post by:
Access 2000: I am trying to delete duplicate records imported to a staging table leaving one of the duplicates to be imported into the live table. ...
6
by: Sven Pran | last post by:
Probably the answer is there just in front of me only awaiting me to discover it, but: 1: I want to build a query that returns all records in...
4
by: Brian | last post by:
I hope this will make sense. I'm trying to filter the records in a table based on records in a 2nd table. The trick is, I can't use a query. I'm...
13
by: Jan | last post by:
Hi I have a database that I use to keep track of the sales promotions that we send to companies. I normally send a mailing based on a subset...
8
by: rbg | last post by:
I did use query plans to find out more. ( Please see the thread BELOW) I have a question on this, if someone can help me with that it will be...
11
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered...
6
by: Dave | last post by:
On my form I have combo boxes. These combo boxes, after updating them, populate respective listboxes that are located below the combo boxes on the...
2
by: srusskinyon | last post by:
I need some help getting unique records from our database! I work for a small non-profit homeless shelter. We keep track of guest information as...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

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.