Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2003
    Location
    Netherlands
    Posts
    18

    Unanswered: serious problem with ON EXIT event in ms access97

    Ok, here's the problem:



    on a form i use some input fields
    some of them are set to force people to enter data into it.

    if someone forgets to enter data, i programmed a dialog box to pop up and tell the user to enter data into the field.
    this goes all well, BUT...

    if someone needs to quit in a hurry, they CANT
    cause if they press my exit button, the popup from the field that has been left empty keeps popping up!


    is there a way(code or something) to ask the user if they really want to exit the database, and telling them that the current record they r working on will not be saved?


    i am using vba code in the exit part of the textbox:


    Private Sub Articlename_Exit(Cancel As Integer)

    ' if no value has entered ( Is Null) tell user

    If IsNull(Articlename.Value) Then
    MsgBox "You must enter a name for the article!", vbExclamation + vbOKOnly, "ERROR:no input in textfield"
    Cancel = True
    End If

    Me.available = True

    the (me.available=true)will set the checkbox status to YES
    (meaning that every newly entered toy is available for lending to people)



    i hope this is enuff info to show what i mean

    i hope someone can help me

  2. #2
    Join Date
    Oct 2003
    Location
    Roanoke, Va
    Posts
    445

    Re: serious problem with ON EXIT event in ms access97

    Originally posted by mrsplash
    Ok, here's the problem:



    on a form i use some input fields
    some of them are set to force people to enter data into it.

    if someone forgets to enter data, i programmed a dialog box to pop up and tell the user to enter data into the field.
    this goes all well, BUT...

    if someone needs to quit in a hurry, they CANT
    cause if they press my exit button, the popup from the field that has been left empty keeps popping up!


    is there a way(code or something) to ask the user if they really want to exit the database, and telling them that the current record they r working on will not be saved?


    i am using vba code in the exit part of the textbox:


    Private Sub Articlename_Exit(Cancel As Integer)

    ' if no value has entered ( Is Null) tell user

    If IsNull(Articlename.Value) Then
    MsgBox "You must enter a name for the article!", vbExclamation + vbOKOnly, "ERROR:no input in textfield"
    Cancel = True
    End If

    Me.available = True

    the (me.available=true)will set the checkbox status to YES
    (meaning that every newly entered toy is available for lending to people)



    i hope this is enuff info to show what i mean

    i hope someone can help me

    I assume that you don't want to save the current record since the

    required input has not been entered so you should be able to clear the

    new record using the "ESC" key. Hit it twice to be sure. Once will reset

    the current action and the other will clear the current record.

    This doesn't cure the logic problem but it's a quick way out.

    Gregg

  3. #3
    Join Date
    Oct 2003
    Location
    Netherlands
    Posts
    18
    thnx for the quick reply

    but it does not work for me

    but i found something out:

    i was thinking of using the default x button on the msaccessform to quit the database in a hurry

    it works perfectly,... but the darn msgboxes i created will still popup,
    and after i close that
    i get an internal access message telling me that the field cannot contain a null value, so i have to close that again
    then i get another message from access telling me that something went wrong, and he asks me if i want to continue quiting( with a yes/no button)


    is there a way to remove those pesky default error messages and substitute them with my own msgbox?


    i think i have to use the form close and form on error events in the events tab of the form,
    but i am totally stuck and dont know where to begin and what code to use for it.



    i think that if i can solve that, my database should work with no problem

  4. #4
    Join Date
    Oct 2003
    Location
    Roanoke, Va
    Posts
    445
    Originally posted by mrsplash
    thnx for the quick reply

    but it does not work for me

    but i found something out:

    i was thinking of using the default x button on the msaccessform to quit the database in a hurry

    it works perfectly,... but the darn msgboxes i created will still popup,
    and after i close that
    i get an internal access message telling me that the field cannot contain a null value, so i have to close that again
    then i get another message from access telling me that something went wrong, and he asks me if i want to continue quiting( with a yes/no button)


    is there a way to remove those pesky default error messages and substitute them with my own msgbox?


    i think i have to use the form close and form on error events in the events tab of the form,
    but i am totally stuck and dont know where to begin and what code to use for it.



    i think that if i can solve that, my database should work with no problem

    Just a quick thought. Try an If Then statement with a boolean variable

    just before the msgbox in your code. If the user trys to exit without

    entering something in the field then set the boolean variable to true,

    otherwise false. When the Exit event fires it will look at the boolean

    variable first (before the annoying message box) and then you can

    decide which course of action to take.

    You might also want to program a form event instead of the individual

    control events.

    This has just been off the top of my head but I hope it helps.

    If you still have no luck then I can try to duplicate what you have done

    see what I would do.

    Good Luck

    Gregg

  5. #5
    Join Date
    Oct 2003
    Location
    Netherlands
    Posts
    18
    ok, i will try it, and will let u know if it works or not
    thnx for the info

Posting Permissions

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