Criteria for Append Query?

C

Crispywafers

Hi. Hope someone can help-- I'm new at this.

I have an append query to the Orders table that should add a record to
the Orders table only if if a StudentID is NOT already present in the
Orders Table with the date of [PARAMETER].

Is this possible? And if so what would be the criteria that I stick in
the criteria field?
 
M

MGFoster

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Perhaps, something like this:

PARAMETERS [thisStudent] Long, [thisDate] Date;
INSERT INTO Orders (StudentID, OrderDate)
SELECT [thisStudent], [thisDate]
FROM ORDERS
WHERE NOT EXISTS (SELECT * FROM Orders
WHERE StudentID = [thisStudent]
AND OrderDate = [thisDate])

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQVMdUoechKqOuFEgEQIowACg8KVKWx928Kib+IqnCfLAlSxtYCIAoIlp
5BQopAgOjfklLdw9gFqihcO/
=smba
-----END PGP SIGNATURE-----
 
C

Crispywafers

Thank you for your help!

That worked like a charm.

Thanks again!


MGFoster said:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Perhaps, something like this:

PARAMETERS [thisStudent] Long, [thisDate] Date;
INSERT INTO Orders (StudentID, OrderDate)
SELECT [thisStudent], [thisDate]
FROM ORDERS
WHERE NOT EXISTS (SELECT * FROM Orders
WHERE StudentID = [thisStudent]
AND OrderDate = [thisDate])

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQVMdUoechKqOuFEgEQIowACg8KVKWx928Kib+IqnCfLAlSxtYCIAoIlp
5BQopAgOjfklLdw9gFqihcO/
=smba
-----END PGP SIGNATURE-----

Hi. Hope someone can help-- I'm new at this.

I have an append query to the Orders table that should add a record to
the Orders table only if if a StudentID is NOT already present in the
Orders Table with the date of [PARAMETER].

Is this possible? And if so what would be the criteria that I stick in
the criteria field?


--
For clarification - The reason for the parameter is students will have
a new order every year... and I want to ensure it's adding the new
year's order even if there student ID is present because they had an
order last year.
 

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