Secting data and inserting it in a table

V

viddom

I am trying to select a group of data from one table to insert it into
another one, but I am new using SQL comands and the one I created is not
working, please take a look and let me know what is wrong:

SELECT [Teilnehmer-Nr]
FROM TeilnehmerStatus
WHERE ((Teilnehmer.Member=True))
INSERT INTO Registrierung([Teilnehmer-Nr],Activity)
VALUES([Teilnehmer-Nr],MountainTrip);

Note:I will use this to create a macro that will take data from one
table,according to some criteria,and will insert it in another table.Also, it
will assign a value,for each copied record, in a defined field.If you know
something similar,please let me know
 
D

David Lloyd

The general format for this type of query would be:

INSERT INTO Registrierung ([Teilnehmer-Nr],Activity)
SELECT [Teilnehmer-Nr], [ActivityFieldOrValueHere]
FROM TeilnehmerStatus
WHERE ((Teilnehmer.Member=True))

I am uncertain about your reference to "assign a value." If you can provide
more information, it would be helpful.

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


I am trying to select a group of data from one table to insert it into
another one, but I am new using SQL comands and the one I created is not
working, please take a look and let me know what is wrong:

SELECT [Teilnehmer-Nr]
FROM TeilnehmerStatus
WHERE ((Teilnehmer.Member=True))
INSERT INTO Registrierung([Teilnehmer-Nr],Activity)
VALUES([Teilnehmer-Nr],MountainTrip);

Note:I will use this to create a macro that will take data from one
table,according to some criteria,and will insert it in another table.Also,
it
will assign a value,for each copied record, in a defined field.If you know
something similar,please let me know
 
V

viddom

Dear David,

this works fine for the first task (Append record from one table to
another), but then I have to do the second task (Update some fields for the
new data). What I want is to make everything at once.

First, I typed:
INSERT INTO Registrierung ( [Teilnehmer-Nr] )
SELECT [TeilnehmerStatus].[Teilnehmer-Nr] AS [Teilnehmer-Nr]
FROM TeilnehmerStatus
WHERE [TeilnehmerStatus].[PermanentContact]=True;

Second, I typed:
UPDATE Registrierung SET VeranstaltungsNr = 19
WHERE ((([Registrierung].[VeranstaltungsNr]) Is Null));

1. It is possible to make everything at once?
2. How can I use a Selection box, so that I can select from different
VeranstaltungsNr, and not just 19 as you see.There is not flexibility?
 
Top