Results 1 to 2 of 2

Thread: Production

  1. #1
    Join Date
    Nov 2010

    Question Unanswered: Production

    I am new at VB, I am trying to solve the following problem and I would really appreciate any help.

    I have a form with several fields. Two of these fields automatically calculate the remaining items in inventory as items are being removed.

    If the number of items that I remove is more than the number of items I currently have in inventory, a Text Box Field automatically displays the message:

    "the amount you are trying to remove is higher than the amount you have”

    If the number of items that I remove is LESS than the number of items I currently have in inventory, the Text Box Field does NOT display the message.

    Question: What I am trying to do is prevent anyone from closing the FORM when they click on the “close form icon” if the Text Box Field is displaying the message, and ONLY allow the user to close this form if the message is not display. Is this possible.

  2. #2
    Join Date
    Mar 2009
    Provided Answers: 14
    An Access form has a CloseButton property. If you set this property to False (or zero), the close button in the System menu (ControlBox, in the upper right corner) of the form will not be available. Unfortunately you can only define this property in Design view, so:
    If <Condition> Me.CloseButton = True Else Me.CloseButton = False
    will not work, it must be defined once for all.

    You can also set the Cancel parameter to True in the Form_Unload event:
    Private Sub Form_Unload(Cancel As Integer)
        If <Condition> Then Cancel = True
    End Sub
    But I cannot know what consequences this can have in your application, it depends on how the form is built and which code it contains.
    Have a nice day!

Posting Permissions

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