473,396 Members | 1,847 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,396 software developers and data experts.

Help with error messages in access

Hi i am creating a database for a college Military Science department and have it just about done. I am encountering some issues with the debug phase. I need some error messages that are user friendly.

For instance:

I have a form that cadets will fill out. Information such as name, unit name, grade level, gpa, ect. ect.

When the teachers enter this into the database through the cadet form I want friendly error messages to appear if there is an empty field. Either when a save button is clicked or the text box loses focus. I have tried using the error codes (3314, ect.) but the code window will not return a code when I click save and an empty field is present, i do get the standard message. It does return the 3314 code when I click the "x" to close the form.

Any ideas?
Dec 11 '07 #1
4 3400
ADezii
8,834 Expert 8TB
Hi i am creating a database for a college Military Science department and have it just about done. I am encountering some issues with the debug phase. I need some error messages that are user friendly.

For instance:

I have a form that cadets will fill out. Information such as name, unit name, grade level, gpa, ect. ect.

When the teachers enter this into the database through the cadet form I want friendly error messages to appear if there is an empty field. Either when a save button is clicked or the text box loses focus. I have tried using the error codes (3314, ect.) but the code window will not return a code when I click save and an empty field is present, i do get the standard message. It does return the 3314 code when I click the "x" to close the form.

Any ideas?
Place similar code to what I am showing you in the BeforeUpdate() Event of the Form, this way the Field Validation will be centralized, and regardless of which mechanism you may use to Save the Form, the Event will be fired and the Record will not be Saved until all Required Fields contain data.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2. If IsNull(Me![Field1]) Then
  3.   MsgBox "You must enter a value in <Your Field Name>", vbExclamation, "Missing Entry"
  4.     Cancel = True: Me![Field1].SetFocus
  5. ElseIf IsNull(Me![Field2]) Then
  6.   MsgBox "You must enter a value in <Your Field Name>", vbExclamation, "Missing Entry"
  7.     Cancel = True: Me![Field2].SetFocus
  8. End If
  9. End Sub
Dec 11 '07 #2
Place similar code to what I am showing you in the BeforeUpdate() Event of the Form, this way the Field Validation will be centralized, and regardless of which mechanism you may use to Save the Form, the Event will be fired and the Record will not be Saved until all Required Fields contain data.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2. If IsNull(Me![Field1]) Then
  3.   MsgBox "You must enter a value in <Your Field Name>", vbExclamation, "Missing Entry"
  4.     Cancel = True: Me![Field1].SetFocus
  5. ElseIf IsNull(Me![Field2]) Then
  6.   MsgBox "You must enter a value in <Your Field Name>", vbExclamation, "Missing Entry"
  7.     Cancel = True: Me![Field2].SetFocus
  8. End If
  9. End Sub
Alright. Now if I have 13 fields in the form would I just continue through to "field13"?
Dec 11 '07 #3
missinglinq
3,532 Expert 2GB
You could or you could loop thru the controls a variety of ways. Here's one example. It requires that you goto Properties - Other and enter a question mark (no quotation marks) in the Tag Property of each control you want to check. You can do this in one fell swopr by selecting all of the controls and changing the Tag property enmasse as it were.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2. Dim Msg As String, Style As Integer, Title As String
  3.    Dim DL As String, ctl As Control
  4.  
  5.    DL = vbNewLine & vbNewLine
  6.  
  7.    For Each ctl In Me.Controls
  8.  
  9.      If ctl.Tag = "?" Then
  10.        If Trim(ctl.Value & "") = "" Then
  11.  
  12.         Msg = "'" & ctl.Name & "' is Required!" & DL & _
  13.                "Please enter a value or hit Esc to abort the record . . ."
  14.          Style = vbInformation + vbOKOnly
  15.          Title = "Required Data Missing! . . ."
  16.          MsgBox Msg, Style, Title
  17.          ctl.SetFocus
  18.          Cancel = True
  19.          Exit For
  20.          End If
  21.       End If
  22.    Next
  23. End Sub
  24.  
Welcome to TheScripts!

Linq ;0)>
Dec 11 '07 #4
ADezii
8,834 Expert 8TB
Alright. Now if I have 13 fields in the form would I just continue through to "field13"?
Another option is to set the Required Property of these 13 Fields in the Table to Yes. If the Required Property is set to Yes, when you enter data in a Record, you must enter a value in the field or in any control bound to the field, and the value cannot be Null.
Dec 11 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Covi | last post by:
Hello, I have a SS2K (SP3) that is appending very wierd looking error messages to the SQL Server Log (Current). The messages are not formatted as other log entries. The messages suggest some...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
13
by: PamelaDV | last post by:
I have a database split for back end and front end and my back end (my data) has been corrupting like crazy lately. Today we have compacted and repaired like 4 times within an hour. The database...
10
by: Brian Conway | last post by:
I have no idea what is going on. I have a Login screen where someone types in their login information and this populates a datagrid based off of the login. Works great in debug and test through...
3
by: Kris van der Mast | last post by:
Hi, I've created a little site for my sports club. In the root folder there are pages that are viewable by every anonymous user but at a certain subfolder my administration pages should be...
0
by: Adam Getchell | last post by:
I'm attempting to write a custom Authentication module using http://www.15seconds.com/Issue/020417.htm I looked at http://support.microsoft.com/default.aspx?scid=kb;EN-US;307996, but it doesn't...
0
by: Joergen Bech | last post by:
Fairly new to ASP.NET 1.1. Getting the error below when running application on a web server outside of my control, but only the first time I run it: 1. After a long period of inactivity (or...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
32
by: robert d via AccessMonster.com | last post by:
I'm looking at converting DAO to ADO in my app. All of my DAO connections are of the following structure: Dim wsName As DAO.Workspace Dim dbName As DAO.Database Dim rsName As DAO.Recordset ...
1
by: CodeSeeker | last post by:
I have an application, which uses pop3 to read the messages from the mailbox, and it has been working fine for so many year. We recently have started changing this application to use java mail IMAP 4...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.