Trying to create a rotation of order in my deluge scripting

Trying to create a rotation of order in my deluge scripting

My database is as follows:

I have two forms (call them F1 and F2), both of which have Name, Email, and Zip Code fields. Currently, I have it set up so that when a record is submitted in F2, and if the Zip Codes for F1 and F2 match, the record with the matching Zip Code in F1 receives an email.

But here's the problem. Sometimes more than one record in F1 has a matching ZipCode. As it stands right now, if 3 records in F1 match a Zip Code in F2, the record with the earliest "Added Time" always receives an email, and the other two records never receive an email. It appears that the script defaults to the record with the earliest "Added Time."

I want only one record at a time in F1 to receive an email whenever a matching Zip Code is found (I know how to make all records receive an email, and don't want that). But I would like to make it so that, for instance, wen one of the three records with Zip Code 99999 receives an email, that record will not receive another until the other two records have receive an email as well - thus creating a rotation of order.

I can think of three ways to do this, but none of these have worked because I cannot figure out a way to do it with the commands available:

1) Since the system always defaults to the record with the earliest "Added Time" every time a record in F1 sends out an email prompted by a Zip Code match in F2, the "Added Time" value will change to the current time. I have not been able to make this work because the system will not permit the "Added Time" values to be modified.

2) Change the system default selection of records from earliest "Added Time" to earliest "Last Modified Time." This would be perfect since every time an email is sent, I also have a command that enumerates the number of emails a record sends out, thus modifying the record whenever it sends an email. This would result in a neat rotation of order. But I have not seen any menu where I can modify the "Added Time" default.

3) I could also write a script so that the email is sent to the earliest "Last Modified Time" in a specified Zip Code 99999 group. But I have not figured out a way to write a script that permits relational instructions between records (e.g., Send email to record with lowest value in XYZ field).

I'm out of ideas here, and I'm open to suggestions.