Validating Primary Key before opening a new form

simonI

Registered User.
Local time
Today, 01:22
Joined
Dec 22, 2005
Messages
25
Folks,

i have two forms with a command button on the first which opens the other...

is there a way of getting this button to validate the primary key (i.e. make sure its not a duplicate) before it trys to open the next form??

i've tried to call the next record function (as the button seems not allow the next record to continue) but all this has done is delete the record and open the new form rather than stopping the action...

any help much appreciated

cheers

si
 
In the ON_Click of your button, you could run a DCOUNT against the primary key, and if it is >1 (or <> 1 or <> 0, which ever is correct) cancel the event.
As one way.
But if the primary key is suppose to be unique, don't you have a NO DUPLICATES on it to prevent that?
 
sorry new to access how do you do the no duplicates or the Dcount....

cheers again..
 
On your table, if you go into design mode, check the properties of the primary key, one of the options are no-duplicates. If this is set you can not enter a duplicate value into the PK field. If it is NOT set, it will not let you set it until only unique values exist.
DIM CntUm as integer
CntUm = DCOUNT("PKcolumn","TableName")
 
thanks for the help...

much appreciated!
 

Users who are viewing this thread

Back
Top Bottom