Insert a record

S

shapper

Hello,

I have an Access database table, named web_MailingList, with 4 fields:
SubscriberName, SubscriberEmail, SubscriberDate, SubscriberId

SubscriberId is the primary key and an autonumber.
I want to insert a new record in the database.

I created the following query:

INSERT INTO web_MailingList ( SubscriberName, SubscriberEmail,
SubscriberDate, SubscriberId )
SELECT web_MailingList.SubscriberName, web_MailingList.SubscriberEmail,
web_MailingList.SubscriberDate, web_MailingList.SubscriberId
FROM web_MailingList
WHERE (((web_MailingList.SubscriberName)=[@SubscriberName]) AND
((web_MailingList.SubscriberEmail)=[@SubscriberEmail]) AND
((web_MailingList.SubscriberDate)=[@SubscriberDate]));

I am asked for the values but then the record is not inserted.
What is wrong?

Thanks,
Miguel
 
N

Neil Sunderland

shapper said:
I have an Access database table, named web_MailingList, with 4 fields:
SubscriberName, SubscriberEmail, SubscriberDate, SubscriberId

SubscriberId is the primary key and an autonumber.
I want to insert a new record in the database.

I created the following query:

INSERT INTO web_MailingList ( SubscriberName, SubscriberEmail,
SubscriberDate, SubscriberId )
SELECT web_MailingList.SubscriberName, web_MailingList.SubscriberEmail,
web_MailingList.SubscriberDate, web_MailingList.SubscriberId
FROM web_MailingList
WHERE (((web_MailingList.SubscriberName)=[@SubscriberName]) AND
((web_MailingList.SubscriberEmail)=[@SubscriberEmail]) AND
((web_MailingList.SubscriberDate)=[@SubscriberDate]));

I am asked for the values but then the record is not inserted.
What is wrong?

Because the SELECT statement is causing the query to look in
webMailingList for a record that matches what you've typed in, and
since it doesn't exist yet no new record gets added by the INSERT.

Try this instead:

INSERT INTO web_MailingList
(SubscriberName, SubscriberEmail, SubscriberDate)
SELECT [@SubscriberName], [@SubscriberEmail], [@SubscriberDate]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top