Re: SQL Question; Populating one table with data from another table.
- From: "Jan T." <post@xxxxxxxxxxxxxx>
- Date: Wed, 26 Apr 2006 18:10:48 +0200
That sounds like the right way to do it. However, I am a newbie when it
comes
to SQL. I successfully made a recordset from table "tblCustomers" with
StatusID <> 2.
But, I failed generating new records in table "tblPayments" based on the
query
from "tblCustomers". I want to generate one new payment (record) for each
Customer in qryCustomers. That is, if I have 18 Customers, then 18 new
payments
should be added to the table "tblPayments".
INSERT INTO tblPayments(CustomerID)
FROM qryCustomers(CustomerID)... (but this does not work, right...?).
I know that the general syntacs is something like this:
INSERT INTO table_name (column)
VALUES (value)
However, I can't figure out how to write my SQL command to make it work?
Any idea?
Thank you in advance.
Jan T.
"Jeff Boyce" <nonsense@xxxxxxxxxxxx> skrev i melding
news:upQ3GuKaGHA.3652@xxxxxxxxxxxxxxxxxxxxxxx
Jan
Can you come up with a query that returns all the customers with StatusID
<> 2 from your ???? table? If so, you can use THAT query as a starting
point to create a new query and convert it to an append query, appending
new payment records.
By the way, I assume you are creating a true payment record (with an
actual payment amount), rather than a dummy payment record. What amount
are you putting in for someone with StatusID <> 2?
Regards
Jeff Boyce
Microsoft Office/Access MVP
"Jan T." <post@xxxxxxxxxxxxxx> wrote in message
news:esPJE7JaGHA.4580@xxxxxxxxxxxxxxxxxxxxxxx
I have a database containing table "tblCustomers" and
table "tblPayments".
Now, I want to run a query to Insert new payments for certain
customer that have some criteria. That is, if the customer has
StatusID <> 2, a new record should be added to the table
tblPayments. Is this possible to do in a query?
The table tblPayments has the following fields:
PaymentID
CustomerID
PaidAmount
Date
I tried to do this with VBA but it failed. It would probably be
much easier to do it with SQL.
Any help would be very much appriciated. Thank you in advance.
JGT.
.
- Follow-Ups:
- Re: SQL Question; Populating one table with data from another table.
- From: Jeff Boyce
- Re: SQL Question; Populating one table with data from another table.
- References:
- Prev by Date: Re: Problem with dates
- Next by Date: Re: Problem with dates
- Previous by thread: Re: SQL Question; Populating one table with data from another table.
- Next by thread: Re: SQL Question; Populating one table with data from another table.
- Index(es):
Relevant Pages
|