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

Using Nulls on Beforeupdate of form and Exiting w/o errors

Researcher
Hello,

I have successfully validated my form fields thru the use of Isnull statements in the beforeupdate event of a form, works great. However when I attempt to exit the form, my first field has the focus due to a tab stop 0. When leaving the form the field message appears "must complete this field prior to exiting form.
How can I disable the isnull check when exiting? I tried changing the focus but did not work. Any ideas would be appreciated...

Thank You,

Researcher
Aug 27 '08 #1
4 1771
missinglinq
3,532 Expert 2GB
Validation data insuring that a field is populated is supposed to execute if the user tries to exit the form when the field on the current record is empty. Are you saying that the field in questioned has data but the message is appearing anyway?

You need to post your Form_BeforeUpdate sub so that we can look at it.

BTW, the first field having focus when you exit the form is not because it has a Tab Stop of 0, that's just coincidental.

Welcome to Bytes!

Linq ;0)>
Aug 27 '08 #2
No, Let me explain further. After data is entered into the form and the record has been saved to table, the form clears and awaits a new record entry, however when attempting to exit the form thru an exit button, the validation check occurs because of no data in the field or fields. I can still exit the form, but without viewing those validation error messages. How can I exit the field w/o viewing the messages and still have field/form validation w/o null entries?

I realize the tab index number is only valid if you have a tab stop, setting the focus to that respective field controls the first field assigned.

Here is the code in the beforeUpdate event of the form:
Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Form_BeforeUpdate(Cancel As Integer)
  3.  
  4.    If IsNull(Me.Events) Or Me.Events = "" Then
  5.         MsgBox "You must Select an Event for this field ", vbCritical
  6.         Cancel = True
  7.         Me.Events.SetFocus
  8.       Exit Sub
  9.    End If
  10.  
  11.    If IsNull(Me.NoofCalls) Or Me.NoofCalls = "" Then
  12.         MsgBox "You must enter the number of calls for this event, if no event enter zero, the field cannot be blank", vbCritical
  13.         Cancel = True
  14.         Me.NoofCalls.SetFocus
  15.       Exit Sub
  16.    End If
  17.  
  18.    If IsNull(Me.BoxOfficeCalls) Or Me.BoxOfficeCalls = "" Then
  19.         MsgBox "You must enter the Box Office Calls, if no event, enter a number greater then zero, otherwise enter a zero, the field cannot be blank", vbCritical
  20.         Cancel = True
  21.         Me.BoxOfficeCalls.SetFocus
  22.       Exit Sub
  23.    End If
  24.  
  25.    If IsNull(Me.Operator) Or Me.Operator = "" Then
  26.         MsgBox "You must enter an operator name, the field cannot be blank", vbCritical
  27.         Cancel = True
  28.         Me.Operator.SetFocus
  29.       Exit Sub
  30.    End If
  31.  
  32.    If IsNull(Me.Shift) Or Me.Shift = "" Then
  33.         MsgBox "You must enter the operator's shift, the field cannot be blank", vbCritical
  34.         Cancel = True
  35.         Me.Shift.SetFocus
  36.       Exit Sub
  37.    End If
  38. End Sub
Aug 27 '08 #3
NeoPa
32,556 Expert Mod 16PB
The point here is that if you close the form with pending amendments to the data, then it saves those changes away for you. Not good to lose the validation for the convenience of exiting quickly.

I would consider using Me.Undo in your Exiting code before trying to exit. That way it assumes any changes should be aborted rather than saved.

Does this make sense?
Aug 30 '08 #4
missinglinq
3,532 Expert 2GB
After data is entered into the form and the record has been saved to table, the form clears and awaits a new record entry, however when attempting to exit the form thru an exit button, the validation check occurs because of no data in the field or fields.
The validation checks in the Form_BeforeUpdate will not occur simply because a "blank" new record has been displayed. The BeforeUpdate event will only fire if something has been entered into at least one of the fields, by either physically entering the data, or by assigning data to a control on a new record via code, such as assigning the current date to a field or assigning a generated ID number to the record..

If you have something like this coded, doing as NeoPa suggested, in your Exit code, with

If Me.Dirty Then Me.Undo

should solve the problem.


You might also check your code and make sure that you haven't put code in the OnExit or LostFocus event of a that first textbox you mentioned in your original post. Even on a new, non-dirtied record, code in either of these events will be fired when closing the form.

Linq ;0)>
Aug 30 '08 #5

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

Similar topics

4
by: William Wisnieski | last post by:
Hello Everyone, Access 2000 I have a form with multiple pages on it. There is one text field on the third page of the form that I need the user to complete before leaving the form or moving...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
4
by: bob bob via AccessMonster.com | last post by:
I'm sure this is a simple one. I have a combo box that, when its data is changed, will trigger a second form to open for input. If the operator declines input, I want the combo box to return to...
9
by: simonmarkjones | last post by:
I want to call a function which does this when the next record button is pressed (calling it from before update) if textboxes are empty then Message box you must fill text box
0
by: Deano | last post by:
My beforeupdate event on the main form fires when a change has been made and the record has not been saved (2 variables are used to track this). Works great but if they make a change in my...
2
by: PC Datasheet | last post by:
In a form/subform I have an unbound combobox in the form header that sets the value of a field in the subform so that it does not have to be entered for each record. In the BeforeUpdate event of...
6
by: lorirobn | last post by:
Hi, I have a form with a continuous subform. I am working on putting validations in for the subform's required fields. Being somewhat new to Access (or rather, an antiquated mainframe...
14
by: ml_sauls | last post by:
I've built a system to enter and manage purchase orders. This is in use by >10 clients. Some use it in Access 97, most are in A2k. About half use it through a Citrix implementation. It is...
2
by: thatguyNYC | last post by:
Hello-- I have a form that lets the user edit the values in a lookup table. The form is bound to a table and has one textbox on it. The record nav buttons are enabled. On the top half of the...
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
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:
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
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.