A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How do I copy a record from one query to another?



 
 
Thread Tools Display Modes
  #1  
Old September 23rd, 2009, 08:40 AM posted to microsoft.public.access.queries
Frank Martin
external usenet poster
 
Posts: 162
Default How do I copy a record from one query to another?

I have to create a Debtor account in my general ledger.

Therefore my aim is to copy some fields of a record from
the query "QryInvoiceTotals" into another query
"QryLedgerTxns".

The fields in each query are of the same type, but with
slightly different names.

The queries are quite separate in the database.

Can someone give me a start? I have tried a "SetValue"
macro with no success.

Please help, Frank








  #2  
Old September 23rd, 2009, 02:11 PM posted to microsoft.public.access.queries
Dale Fye
external usenet poster
 
Posts: 2,651
Default How do I copy a record from one query to another?

Frank,

You cannot copy a record from a query to another query (period).

You can however copy a record from a query to a table, which is returned by
another query.

The syntax for this would be something like:

INSERT INTO tblDestination (field1, field2, field3)
SELECT field1, field2, field3
FROM qryInvoiceTotals

Exactly what fields you need to populate in the destination table will
depend on the table, and if you don't set the values appropriately, it still
might not show up in qryLedgerTxns.

----
HTH
Dale



"Frank Martin" wrote:

I have to create a Debtor account in my general ledger.

Therefore my aim is to copy some fields of a record from
the query "QryInvoiceTotals" into another query
"QryLedgerTxns".

The fields in each query are of the same type, but with
slightly different names.

The queries are quite separate in the database.

Can someone give me a start? I have tried a "SetValue"
macro with no success.

Please help, Frank









  #3  
Old September 23rd, 2009, 05:25 PM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default How do I copy a record from one query to another?

On Wed, 23 Sep 2009 17:40:57 +1000, "Frank Martin" wrote:

Therefore my aim is to copy some fields of a record from
the query "QryInvoiceTotals" into another query
"QryLedgerTxns".


Data is not stored in queries. Data is stored in tables, and ONLY in tables. A
Query is just a view of a table, a way of selectively retrieving certain
records and fields from the table and arranging them as desired. Changing or
inserting data into a Query changes or inserts data into the underlying Table
(if the query is updateable).

What tables underlie these queries? How are the tables (not the queries)
related, if at all?
--

John W. Vinson [MVP]
  #4  
Old September 24th, 2009, 08:25 AM posted to microsoft.public.access.queries
Frank Martin
external usenet poster
 
Posts: 162
Default How do I copy a record from one query to another?

Thanks; I figured out that I need an append query for this
task and I managed to make one.

The aim was to append records from "QryINVOICEtotals" (a sum
query to add the invoice lines totals for an invoice) to
"tblLedgerTxns".

I used a copy of this query to make the append one.

I had to make some adjustments to the "QryINVOICEtotals" by
introducing a new field called "LedgerAccount" which is a
number designating which ledger account the Debtors are
inserted, and this is number 7. I had therefore to fill
this field with 7 for 4500records though I used the "find &
replace" method for this (find "null" and replace with "7".)
The relevant field in the "QryINVOICEtotals" is
automatically filled in with a "7" from a related table
"tblCustOrders" for with the field default value is set at
"7".

The appending only worked after I deleted a primary-key
field (unrequired) from the design grid of
"QryINVOICEtotals".

My next task is to append the "tblLedgerTxns" one record at
a time by using this append query, but I need some form of
prompt to appear when an invoice is completed, asking "Post
to Ledger? Y/N")

How should I start with this task; should I use a macro?

Thank you for the help, Frank








"Dale Fye" wrote in message
...
Frank,

You cannot copy a record from a query to another query
(period).

You can however copy a record from a query to a table,
which is returned by
another query.

The syntax for this would be something like:

INSERT INTO tblDestination (field1, field2, field3)
SELECT field1, field2, field3
FROM qryInvoiceTotals

Exactly what fields you need to populate in the
destination table will
depend on the table, and if you don't set the values
appropriately, it still
might not show up in qryLedgerTxns.

----
HTH
Dale



"Frank Martin" wrote:

I have to create a Debtor account in my general ledger.

Therefore my aim is to copy some fields of a record from
the query "QryInvoiceTotals" into another query
"QryLedgerTxns".

The fields in each query are of the same type, but with
slightly different names.

The queries are quite separate in the database.

Can someone give me a start? I have tried a "SetValue"
macro with no success.

Please help, Frank











  #5  
Old September 24th, 2009, 08:39 AM posted to microsoft.public.access.queries
Frank Martin
external usenet poster
 
Posts: 162
Default How do I copy a record from one query to another?


"John W. Vinson" wrote
in message
...
On Wed, 23 Sep 2009 17:40:57 +1000, "Frank Martin"
wrote:

Therefore my aim is to copy some fields of a record from
the query "QryInvoiceTotals" into another query
"QryLedgerTxns".


Data is not stored in queries. Data is stored in tables,
and ONLY in tables. A
Query is just a view of a table, a way of selectively
retrieving certain
records and fields from the table and arranging them as
desired. Changing or
inserting data into a Query changes or inserts data into
the underlying Table
(if the query is updateable).

What tables underlie these queries? How are the tables
(not the queries)
related, if at all?
--

John W. Vinson [MVP]



Thanks. The ledger transactions are based on one table only
"tblLedgerTxns", though in the relationship screen I have
connected it to two other tables, and the three are
"tblLedgerAccntType" has many "tblLedgerAccnts" has many
tblLedgerTxns." These three connected tables are alone on
the relationship screen.


The "QryINVOICEtotals" is a summary query with a source
"QueryINVOICE." It produces a list of invoices which
themselves are a collection of invoice lines.

The "QryINVOICE" is very detailed and is a joined group of
tables "tblPeople", tblAddressType", "tblPeopleType",
"tblAddressDetail", "tblCustOrders", "tblInvoiceLines",
"tblProducts".

My database has evolved over a long time. But now my
accountants want me to improve the ledger.

Regard,Frank



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:00 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.