Results 1 to 2 of 2
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Thanked 0 Times in 0 Posts

    If Is Null (Access 2000)

    I have a control called Kind on a form.The control kind is a combo box.I want to prevenet saving the record in case the user has not chosen from the combo box. I tried the foollowing
    If Me![Kindid] = "" then
    cancel = true
    however acess does not accept the cancel event.Also i dont want to save the record.Is it possile to give the coomand save.No , give the message" please select from Kind andf then close the form?

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Evergreen, CO, USA
    Thanked 65 Times in 64 Posts

    Re: If Is Null (Access 2000)

    Why not make the field required at the table level? The only problem is that you don't get an error in that situation until the user tries to save the record. You could put a validation rule on the control as another strategy - that would warn them if they simply tabbed through the record. Actually you may want both.

    It is also possible to do it in code on the Before Update event of the form, but your code won't catch it because you are checking for an empty string, not null. If you want to check for null, you need to write:

    If IsNull(Me![Kindid]) then Cancel=True

    That's air code BTW, so it may need minor tweaking. You may also want to check for both Null and Empty String depending on your data type.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts