This topic is locked

before add event?

7/6/2006 12:31:59 PM
ASPRunnerPro General questions
S
Spitty author

I posted a topic about my scenario problem, but it was confusing and made no sense... this is basically what i want to do:
My table contains a field called 'featuredOrder', this field contains any number between 1 - 8 (via a drop down list on the add page).

I want to apply an event code on the add page which checks if the number selected is located in any other record within the field 'featureOrder', and prompt the user to either select a different number, or delete the contents of 'featuredOrder' field in the record found with the same numer. Basically i do not want to duplicate the numbers in this field.
What event code could i use 'beforeAdd'? and how do i go about writing it?

Sergey Kornilov admin 7/6/2006

Well, it's still kind of confusing because you like to present user with two different and not related options - modify another record or reenter a new one. Also it appears you cannot enter more than 8 records into this table.
Personally I think you need to modify Add page to present only valid numbers in this drodown box. You will need to modify SQL query that populates this dropdown box to select available numbers only like

select Number, Number from TableName

where number not in (select number from TableName)
S
Spitty author 7/7/2006

So this SQL populated dropdown list will only display number 1-8 that are currently not within the table already?

There are more than 8 records in the table and the column 'orderFeature' will be populated by the dropdown list and will sometimes be empty, only 8 records out of say 50 will only have content in this field.
I like the fact the user can only select a number that isn't already taken by another record however, i wanted to give the user the option to enter any of the 8 numbers, and if another record has one of the 8 numbers for it to be removed from another record... so it does not duplicate.
For example, table contain 50 records, 8 of these records contain 1 - 8 in the 'orderFeature' column, the user decided to add another record (51 records) this record will have number 8 (from the dropdown list)in 'orderFeature' field.

However, obviously another record already contains this number in that field, and we do not want to duplicate numbers in this field for the records. The user can only use this number if the old record has that field content deleted?

I dont want the user to have to manually go to the old record and delete the content of the 'orderedFeature' field, so they can add a new record.
Thank you for your help so far!