Solved

records rom one table to another

Posted on 2011-03-10
8
230 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
  • 4
  • 3
8 Comments
 
LVL 39

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
 
LVL 39

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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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 39

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 39

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

708 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now