Flagging the user IF certain number of records have been registered

C

Craig Cerff

Customer complaints are entered into tables. How do I
flag the user, say via msgbox, that there have been 3
complaints for a certain product (field 1) on the same
best before date (field 2). Either in a form when the
information is being updated or when the database is being
opened.
Thanks
Craig
 
S

Steve Schapel

Craig,

The first step is to create a query that will see if any records meet
the conditions you mentioned. This would be a Totals Query. If you are
using the query design window, you would select Totals from the View
menu, leave Group By in the Totals row of the query design grid for both
the Product and BestBeforeDate columns, and then add the table's
primary key field to the grid, and put Count in the Totals row of this
column, and >2 in the Criteria row. The SQL for this query will look
something like this...
SELECT Product, BestBeforeDate, Count(ComplaintID) AS ProductComplaints
FROM YourTable
GROUP BY Product, BestBeforeDate
HAVING Count(ComplaintID)>2

There would be a number of ways your could proceed from here. One
option would be to base a continuous view form on this query, and then
use a macro to open this form if there are any records. Such a macro
would use the OpenForm action, and then in the Condition of the macro,
something like this...
DCount("*","NameOfYourQuery")>0
If you have a form which automatically opens whenever the database is
opened, this macro could be assigned on the On Load event of this form,
so the user is alerted to any such data every time the database is
opened. Of course, you will also need a date criteria, or else some way
of "processing" the offending complaints records, otherwise once there
is a triple-complaint it will keep popping up on the list forever... but
I don't know enough about your project to advise further on this.
 

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