Solved

records rom one table to another

Posted on 2011-03-10
8
273 Views
Last Modified: 2012-05-11
I have a detail finance data in a table. I added a checkbox and combobox that link to invoice ID table, when the user select invoiceID from the combobox and ceck the checkbox, I want a copy of this record to go to the invoice detail table with the right invoiceID.

First table where the deytails are: called Detailfinance_tbl and copy of the record should go to table called invoicedetail table.

The fields that should be copied after selecting the invoiceId and clicking on the checkbox is is Amount,InvoiceID, and description

Is there a way to do this?
0
Comment
Question by:HappyAlways
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 40

Expert Comment

by:als315
ID: 35094383
Create add query from source table to resulting, add conditiion for invoiceID (use builder, select your form and invoiceid combobox).
Try run it. If all will be working, you can run it from your checkbox with afterupdate event:
docmd.setwarnings False
docmd.openquery "YourQueryName"
docmd.setwarnings True
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35096707
<I want a copy of this record to go to the invoice detail table with the right invoiceID.>

If I am reading this correctly, this will create Duplicate data.
What is the reason why this data cannot be "Linked" to the Invoice detail table?
0
 

Author Comment

by:HappyAlways
ID: 35097824
Actually, it will select the right records to be part of the invoice details table. The invoice detail table is editable.
This worked perfectly, but the only problem I am facing is that when select invocie number from combobox and click on the checkbox, it copy the records multiple time. example:

Inv#        amount         desc
4403        50.00          food
4403        70.00           drink
4403        20.00            car
4403         80.00           train

if i select the checkbox in 5 records, it will copy them total 20 times. If I click on one of the records, it copies them once.

How can I make it work only to select the one that has the checkbox?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 40

Expert Comment

by:als315
ID: 35098334
"if i select the checkbox in 5 records, it will copy them total 20 times"
You have something wrong in logic. May be you can upload your DB with sample data?
0
 

Author Comment

by:HappyAlways
ID: 35098736
i don' think I have anything wrong with the logic. I am not sure if it has something to do with the datasheet subform.

The query is :

INSERT INTO InvoiceDetails_tbl ( InvoiceID, Total, Description, UnitTypeID, UnitPrice )
SELECT GLDetails_tbl.InvID, GLDetails_tbl.Amount, GLDetails_tbl.[CO Doc Line Item Txt], GLDetails_tbl.[Cost Element], GLDetails_tbl.Amount1
FROM GLDetails_tbl
WHERE (((GLDetails_tbl.InvID)=[Forms]![N_ProjectSub_frm]![Gldetails_subfrm].[Form]![InvID]));


Private Sub Invoice_AfterUpdate()
DoCmd.SetWarnings False
DoCmd.OpenQuery "GLApend_qry"
DoCmd.SetWarnings True

End Sub
0
 
LVL 40

Expert Comment

by:als315
ID: 35105677
How many records you see, if GLApend_qry is opened manually (from designer)? Form N_ProjectSub_frm should be also opened.
0
 

Author Comment

by:HappyAlways
ID: 35107897
I see the correct number. 5 records
0
 
LVL 40

Accepted Solution

by:
als315 earned 500 total points
ID: 35108288
Query should add only 5 records. May be it is atarted more then once?
Try to comment line:
DoCmd.SetWarnings False
You will be asked about every query.
0

Featured Post

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question