Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2010

    Unanswered: Displaying a message box and closing a form


    I have two forms, in the first form the user enters data into a text box, I then have a button that opens another form, this form is linked to a query and finds the record based on what the user has entered into the text.

    I'm trying to add in some code so when no record is returned a message box appears and the form closes automatically. When there is no record then my primary key on the second form automatically becomes "0".

    In the form load section of the second form I have the following:

    If VoucherNo = 0 Then
    MsgBox "There is no record to show"
    End If

    It only seems to half work. The message box appears but when I click Ok on the message box the form loads up instead of closing down.

    Where am I going wrong?

  2. #2
    Join Date
    Jul 2004
    South Dakota
    Have you tried checking to see if any records exist before opening the second form?

    So in the first form when the button is clicked, check to see if a record exists and if it does open the second form. Otherwise, just set your text box to 0.


Posting Permissions

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