Hi Mark.
The Required property at the engine level does work, i.e. the record is not
saved with the field blank. The problem is with the Close action.
When you use the Close action/method, Access silently *loses* your entry
without any message to notify you. To me, that is a major data-loss bug in a
piece of software that is supposed to save entries by default, but all my
attempts to get MS to fix this (over many years) have failed.
If it is any comfort, you are just one in a long queue of people who have
been stung by this. Many just lose data without ever figuring out why
"Access sometimes doesn't save properly."
Once you know about this bug, it is not too difficult to work around it:
always force an explicit save before you issue a Close. Example:
If Me.Dirty Then
Me.Dirty = False
End If
DoCmd.Close acForm, Me.Name
That code raises an error if Dirty is not set to False (i.e. the record
cannot be saved), so control passes to your error handler and the Close is
never called.
For some of the other unfixed flaws that remain unfixed through many
versions of Access, see:
http://members.iinet.net.au/~allenbr...ips.html#flaws
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Mark" <mm*****@earthlink.net> wrote in message
news:N8******************@newsread2.news.atl.earth link.net...
Access97 ---
I set the Required property for a field at the table level and I have a
form that contains that field. When I click the Close button at the top left of
the screen, I get an error message when the field is blank and Access will not
let me save the record. However, I also have a Close command button with the
code: DoCmd.Close
When I click the button, the form closes with no error message although
the field is blank. I tried changing the code to:
DoCmd.Close acForm, "MyForm"
and made no difference; the form closed although the field was blank.
What is the difference between closing the form with the form's close
button and closing the form with a coded command button? Can the Required property be
made to work with a coded command button?
Thanks!
Mark