Unique entries code

You provided me with a code for no duplicate. Can I get a code for no unique entries. Thank you

I’m not sure if this is what you want, but to set 'No Unique" to a field, double click on the field name in the data sheet which will display Field Properties. There is a pop up for “Duplicates”. Set it to “No Unique”.

That popup is there in Field Properties, but IIRC there still isn’t any underlying code implementing those options. I think Jim posted that it could be implemented in different ways—no exceptions or warn but allow exceptions—and he hadn’t yet figured out which way was best.

I haven’t tested this, but I think changing the > to = would do the trick.

if linecount(lookupall("",info("fieldname"),«»,info("fieldname"),cr()))=1
    alertsheet "This is a unique value"
endif

Here is the link to the original no duplicates topic.

I have come up with a method to simulate the action of Panorama 6 regarding the “No Unique” field option. The trick is an AppleScript to key command-Z and undo the current entry so it goes back to what it originally was. This trick would also give you a programmatic way to force an undo in other areas. The scheme requires some generic code to be entered into any field where you want this option active as well as a procedure that is called when editing is finished.

Make a procedure called .unique with this code:

if linecount(lookupall("",info("fieldname"),«»,info("fieldname"),cr()))=1
    let recordID=info(“serverrecordid”)
    alertsheet "This value is not already in this field. Click OK to add anyway, or Cancel to re-edit cell.", "Buttons","Cancel,OK","style","c"
    If info("dialogtrigger")="Cancel"
        applescript |||
        tell application "PanoramaX"
            activate
        end tell
        tell application "System Events"
            keystroke "z" using command down
        end tell|||
        find info("serverrecordid")=recordID
        field callField+""
        editcellstop
    endif
endif

Put this code in the Code panel for any field you want to catch unique input:

letfileglobal callField=info("fieldname")
call .unique

Any unique entry into one these fields will generate an alert sheet with the old Panorama 6 warning message and two buttons for Cancel and OK (the two are in reverse order from those of Panorama 6 but the Cancel is still set as the default). If OK is pressed things go on as entered. If Cancel is pressed the new value is replaced with what was originally there and the cell is reopened for editing.

That worked! Thank you