Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / March 2007

Tip: Looking for answers? Try searching our database.

Required Field Msg Box loops.  Can't close form...help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sdh31873 - 08 Mar 2007 18:55 GMT
I have a form with some required fields.  When they fail to enter data in
that field, it pops up a message box.  It takes them back to that field.
What if they don't know the information and they want to close the form?  I
can't get that to work.  I have added a "Close Form" button but it won't stop
prompting with the msgbox from the required field.  Any help in this matter?
Here is the code. Thanks.

[code]Private Sub ContactName_Exit(cancel As Integer)
If IsNull(Me.ContactName) = True Then
 MsgBox "The Contact Name is required", vbExclamation, "Missing Data"
 cancel = True
 Me!ContactName.SetFocus
 Exit Sub
End If

End Sub[/code]
Marshall Barton - 08 Mar 2007 19:48 GMT
>I have a form with some required fields.  When they fail to enter data in
>that field, it pops up a message box.  It takes them back to that field.
[quoted text clipped - 12 lines]
>
>End Sub[/code]

It's difficult to have a "required" field and try to deal
with a user that doesn't know what to enter.  It sounds like
the field isn't really required.

You could try removing the Cancel and SetFocus.  However,
the msgbox will pop up even if the user is just tabbing
through the text boxes to get to the one they want to use.

For that reason, it is more common to use the Form's
BeforeUpdate event instead of individual control events.
However, if the user doesn't know what to enter, all you can
do is pop up a warning.  If the "doen't know" scenario is
moderately common, users will quickly learn to ignore the
warning, rendering it useless.

I prefer to let users enter data in any order at any time
(even over several days).  I provide a button that users can
click to say they think the quote/order/whatever is complete
and can be made "official".  The button's Click event
procedure would the check all the required fields, generate
a message about the missing ones and skip the make it
official step.

If everthing checks out ok, then set a OfficialDate field to
Now() so you know the entry is complete (and maybe should
not be changed anymore).

Signature

Marsh
MVP [MS Access]

sdh31873 - 08 Mar 2007 20:05 GMT
I love the code that was provided to check all the fields beforeupdate on the
form event but I have a subform included.  I need it to check all of those
too.   Any help there?

>>I have a form with some required fields.  When they fail to enter data in
>>that field, it pops up a message box.  It takes them back to that field.
[quoted text clipped - 28 lines]
>Now() so you know the entry is complete (and maybe should
>not be changed anymore).
Marshall Barton - 08 Mar 2007 21:51 GMT
I can't see anything with BeforeUpdate code, but, regardless
of what it does, it can not deal with a user that doesn't
know what to enter at that time.

If you're happy with that approach, then add similar code to
the subform's BeforeUpdate event.  You can not do the
subform checking in the main form because the subform
record, if changed, will be saved before the focus is given
to the mainform.
Signature

Marsh
MVP [MS Access]

>I love the code that was provided to check all the fields beforeupdate on the
>form event but I have a subform included.  I need it to check all of those
[quoted text clipped - 32 lines]
>>Now() so you know the entry is complete (and maybe should
>>not be changed anymore).
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.