How do I prevent an append query from running twice with the same

G

Guest

I am writing a database to keep a record of the labour involved in a seed
treating plant.
Every day the register is taken - yes/no in present colum and the date
inserted as per the date on an unbound form.
The date form has a button which, when clicked, runs an append query and the
data appended to the register table.

My question is:
How do I prevent the data entry clerk from running the append query twice?

I have a count query to count the number of names in the register for that
particular date.
If the count = 0 then no append has been run
I cannot get the If (CountOfNames = 0) then run the qppend query to work.

Can anyone help?
 
J

Jeff Boyce

The generic approach is:

* Use code, preferably run from the click of a command button on a form
* In your code, use the number of records with today's date to decide
whether to run
* You need to look up using recordsets and the .BOF & .EOF (begin/end of
file) property to decide

Or, you could set a uniqe index on the table that rejects duplicates (you
decide what constitutes a duplicate in terms of which fields).

--
Regards

Jeff Boyce
Microsoft Office/Access MVP
Microsoft IT Academy Program Mentor
 
G

Guest

If the business rule is that the records are appended to the table only once
a day, make the date field a unique constraint at the table level. As long as
you are using Date() and not Now() to populate the record, that should stop
it. Just be ready to trap that error at the form.

Another method would be to do a DMax of the date field in the table when you
push the button on the form. If there is a matching date, don't run the
append query.
 

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