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

    On Close (Access 2000)

    In my form i have a control called certificate that i want to make it obligatory to fill in.I want to forbid closing the form without filling in this control.I work on the following
    The code i have written in the OnClose event of the form does not help and actually makes nothing. Even the message dos not appear.

    If IsNull(Me![Certificate])
    MsgBox "Please enter certificate number"
    exit sub
    Me.Undo
    End If
    Why is it so ?

    i

    f isNull Forms!frmClinets!certificate then

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: On Close (Access 2000)

    Is Certificate bound to a field in a table? If so, set the Required property of the field in the table to Yes. You won't need any code.

    If it is not bound to a field, or if you do not want to set Required to Yes, you can use the Before Update event of the form:

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    If IsNull(Me!Certificate) Then
    Me!Certificate.SetFocus
    MsgBox "Certificate must be filled in!", vbExclamation
    Cancel = True
    End If
    End Sub

  3. #3
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    114
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: On Close (Access 2000)

    Thank you for your reply.Yes, it works, when the control is not filled in, the message appears and the records is not saved. But if after that i repeat the closing, then the form is closed. How could i give the command so that the form should not be closed until the control if filled in ?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: On Close (Access 2000)

    You could use the On Unload event of the form, and similar to the code in the Before Update event, set Cancel = True if the control is null.

Posting Permissions

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