Thanks Jim. >>Out of curiosity, what 'other problems' would be caused by setting the underlying table fields to not allow nulls?<< The problems I had were with setting required to yes in the table - could that be because some of the values were null? When required was set to yes in the table, it seemed to mess up my data capturing. Specifically, when my form opens, it runs a series of events & queries that assigns the next available number according to selected site ID, then writes the captured number/date stamp back to the main table. When the table field is set field to required, after I've selected 'ok to assign new number for that site', my detail form where the user inputs further detail against that number comes up blank, none of the information is passed, and the assigned data is not captured. If I change the required to no in the table, the data capture works ok again. It seemed easier (at least to me!) to find a way to check for nulls on the way out of the detail form than go back and figure out what happened in other scenario, since it was working before I added the requirements. >>This may be splitting hairs, but I just want to make sure you're covered: you stated, "...if 3 of the fields are null", rather than, "if any of the 3 fields are null".<< Thank you for the clarification, I hadn't thought it out to that level. Any or all of the fields may be null and even if there's only one null, I want it to stop the user from closing the form because I need that data captured. Keep on splitting hairs, I've got one or two left to spare that I haven't pulled out over this database anyway! Thank you, am off to set up my form with your code . . . wish me luck! :-) "Jim Pettit" <j_e_pettit@hotmail To: <mso@xxxxxxxxxxxxx> .com> Sent by: cc: mso-bounce@freelist s.org Subject: [mso] Re: Access 2002: Checking For Nulls On Form 06/10/2004 09:48 AM Close Please respond to mso ..... Cathy-- Since you don't want to make the bound table fields do the work, your best bet is to simply check the value of the fields before leaving the form. Your best bet is to attach the code to the form's BeforeUpdate event. An example follows: Private Sub Form_BeforeUpdate(Cancel As Integer) If Len(Me.txtRequiredFieldOne & "") = 0 Then MsgBox "Please fill in Field One", vbOKOnly + vbExclamation, "Can't Do That!" Me.txtRequiredFieldOne Cancel = True Me.Undo Exit Sub End If If Len(Me.txtRequiredFieldTwo & "") = 0 Then MsgBox "Please fill in Field Two", vbOKOnly + vbExclamation, "Can't Do That!" Me.txtRequiredFieldTwo Cancel = True Me.Undo Exit Sub End If If Len(Me.txtRequiredFieldThree & "") = 0 Then MsgBox "Please fill in Field Three", vbOKOnly + vbExclamation, "Can't Do That!" Me.txtRequiredFieldThree Cancel = True Me.Undo End If End Sub My example will work with a few fields, but if you've a whole bunch of fields to check, my code would get unwieldy and difficult to maintain; in such a case, you'd probably want to do something fancier. Let us know if you need more examples. This may be splitting hairs, but I just want to make sure you're covered: you stated, "...if 3 of the fields are null", rather than, "if any of the 3 fields are null". If by that you mean that you'd only want to prevent the form from closing if all 3 of the fields are null, your code could look like this: Private Sub Form_BeforeUpdate(Cancel As Integer) If Len(Me.txtRequiredFieldOne & "") + Len(Me.txtRequiredFieldTwo & "") + Len(Me.txtRequiredFieldThree & "") = 0 Then MsgBox "Please fill in the fields", vbOKOnly + vbExclamation, "Can't Do That!" Me.txtRequiredFieldOne Cancel = True Me.Undo End If End Sub Out of curiosity, what 'other problems' would be caused by setting the underlying table fields to not allow nulls? --Jim >>Thought I'd recently seen some code to check for null values on form close, but not finding. I'm needing to do a check on form close that if 3 of the fields are null, a message will pop up telling user which field(s) need to be completed before closing. The form should not close till the data criteria has been met. Can't set the table field to required, that option caused other problems in my form, so I'm thinking the next option is to check the certain fields for null values before closing form. Any ideas? Thank you, Cathy<< ----------------------------------------------------------------------------------------------------- The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. If you are not the intended recipient of this message you are hereby notified that any use, review, retransmission, dissemination, distribution, reproduction or any action taken in reliance upon this message is prohibited. If you received this in error, please contact the sender and delete the material from any computer. Any views expressed in this message are those of the individual sender and may not necessarily reflect the views of the company. ------------------------------------------------------------------------------------------------------- ************************************************************* You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or MicrosoftOffice@xxxxxxxxxxxxxxxx To send mail to the group, simply address it to mso@xxxxxxxxxxxxx To Unsubscribe from this group, send an email to mso-request@xxxxxxxxxxxxx with the word "unsubscribe" (without the quotes) in the subject line. Or, visit the group's homepage and use the dropdown menu. This will also allow you to change your email settings to digest or vacation (no mail). //www.freelists.org/webpage/mso To be able to use the files section for sharing files with the group, send a request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with instructions. Once you are a member of the files group, you can go here to upload/download files: http://www.smartgroups.com/vault/msofiles *************************************************************