473,394 Members | 1,778 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,394 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 2987
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.