Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

records rom one table to another

Posted on 2011-03-10
8
Medium Priority
?
278 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
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
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 2000 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 learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

722 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