473,326 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Required Property

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
Nov 12 '05 #1
3 2982
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

Nov 12 '05 #2
Thanks, Allen! I really appreciate your help.

Mark
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:40***********************@freenews.iinet.net. au...
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


Nov 12 '05 #3
"Mark" <mm*****@earthlink.net> wrote in message news:<N8******************@newsread2.news.atl.eart hlink.net>...
Access97 ---

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?

The sort answer, I believe, is "no." I'd recommend a short bit of
code that manually checks the current status of the required field(s)
in the On Unload (NOT On Close) event for the form. You can execute a
CancelEvent action to stop the form from closing if the field is
empty. (There's a great bit of example code in the CancelEvent help
for Access 97.)

Depending on how you want to treat the situation, you could go the
extra mile and include a message box, set the focus to the required
field's data entry point, and temporarily re-color that field's
background color to red.

Dennis
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Georges Heinesch | last post by:
Hi. My form contains a control (cboFooBar), which has an underlying field with the "Required" property set to "Yes". Now, while filling out all the controls of the form, I have to fill out this...
3
by: Mark | last post by:
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...
3
by: Kejpa | last post by:
Hi, I have a datatable which I try to update but the update fails because a required property of one of the fields is set to True. Where can I find this property? On the Column there's only a...
3
by: CindyRob | last post by:
I am using .NET framework 1.1 SP1, .NET framework SDK 1.1 SP1, with hotfix 82202, Visual studio .NET 2003 with hotfix 823639. I have generated a proxy class using wsdl.exe from a schema that has an...
2
by: Billy | last post by:
Hopefully a simple one, what is the syntax to force a property to be required in a user control? I thought it would below, but it's not: Public Required Property propName() As String
11
by: Naeem | last post by:
I have a Javascript function, which changes a text field of a form into a select field. Following is the function function changeStateField() { var myForm =...
1
by: Denis | last post by:
Hi I have a field called firstname in a table called table1. I have it set as required in a form. How do I display a customized error message rather than the standard one given by Access below ...
0
by: nimeshdotnet | last post by:
Hi All, I have a textbox whose readonly property is set to true. This textbox is also guarded by a required field validator. What i m doing that I have a calendar control whose on date selection i...
0
by: malsh1358 | last post by:
Hi I need check required elements and attributes in JAXB java classes , if there are any value for them place it , otherwise place default value in xml file , because of it I upgrade JAXB2.0 to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.