validate before inserting new record

T

TMGreen

From a continuous form, how do you code to do a record validation prior to
the new record being inserted. The table is a sql table, indexes and keys
are set, but I want to give users an error rather than a system error.

I understatnd how to check the existing table for duplicates, but can't
figure out which event to tie the validation to? - before insert or dirty
or???
 
R

Rick Brandt

TMGreen said:
From a continuous form, how do you code to do a record validation prior to
the new record being inserted. The table is a sql table, indexes and keys
are set, but I want to give users an error rather than a system error.

I understatnd how to check the existing table for duplicates, but can't
figure out which event to tie the validation to? - before insert or dirty
or???

Use the BeforeUpdate event and when validation fails display a message and then
set Cancel = True to stop the update.
 
X

XP

Hi Rick,

I hope you don't mind me jumping in here, I'm not familiar with continuous
forms, but can you do the same thing with a regular form? - I.E. Use the
BeforeUpdate event to validate and block an entry before it hits the table?

Thanks for your answer...
 
T

TMGreen

The problem is I need more info entered into the form than the first
character of the record in order to validate the key for duplicates.

If there another event that is more like a before commit type event?
 
R

Rick Brandt

TMGreen said:
The problem is I need more info entered into the form than the first
character of the record in order to validate the key for duplicates.

If there another event that is more like a before commit type event?

You can use the AfterUpdate event of the control.
 
E

egerds

I use AfterUpdate to check other form or array criteria and if any are
flagged then msgbox or even me.controlnamehere.Undo so the edit isn't
saved to the the bound table.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top