id number used more than once

  • Thread starter Thread starter faapa via AccessMonster.com
  • Start date Start date
F

faapa via AccessMonster.com

good morning all!

this might sound like a dumb question so im sorry in advance....i'd like the
user to be able to delete a record if the id number is used only once...if
the id number is used more than once, it cant be deleted...does anyone know
how this may be written?
 
Good Afternoon to you.

If this is a mass delete the SQL looks something like

DELETE *
FROM <tab>
WHERE <tab.id> IN(
SELECT <tab.id>
FROM <tab>
GROUP BY <tab.id>
HAVING Count(<tab.id>) = 1
)

but I suspect you want to do this record by record!

So code the Before Del Confirm event with something like

If DCount("<id>","<tab>","<id> = " & Me.<id>) <> 1 Then
Cancel = True
Exit Sub
End If

Replace the angle bracket terms above with your table, field and control
names as appropriate.

Regards,

Rod
 
Back
Top