bound controls and required data

  • Thread starter Thread starter L Melville
  • Start date Start date
L

L Melville

Hi,

I have 2 date fields on a form that must be entered, the table properties
are set to 'Required'. On the form I have a save and cancel button, the
code behind the cancel button is;-

if me.dirty then me.undo
docmd.close

now the problem is when editing the data, and deleting one of the dates and
then pressing cancel, the usual access error message about this field being
required is shown. I have even tried storing the dates in variables and
when the cancel button is clicked the old dates are reinserted and it still
doesn't work, is there a way around this?

thanks
lee
 
Well, the solution that I *know* will work is to make your form an unbound
form. In the Open event, populate your form fields. In the cmdSave_Click
event, save the data back to the table(s), checking first to make sure that
all required fields are entered. This is my preferred way to handle popup
Save/Cancel situations.

Without playing around with what you have, I can't say if I have a good way
to make this work when Bound. You might be able to put some code in your
AfterUpdate event in your date textboxes that would reset the values. But I
like the first way...
 
Back
Top