Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Close form (A2K SP3)

    I have a frmCheckInLast which I want to close so that a new record will not be created if the operator tabs thru the last field. The last field in the tab order is AccountReceivable which is a field the operator can not update. Currently, if the operator hits tab or enter on this field, a new record is created.

    My thought was to create an OnLostFocus event

    Private Sub AccountReceivable_LostFocus()
    DoCmd.Close acForm, "frmCheckInLast", acSaveYes

    End Sub


    I get a run time error
    "This action can't be carried out while processing a form or report error."

    Any assistance would be appreciated.


    Tom

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

    Re: Close form (A2K SP3)

    The On Lost Focus event of a control is not suitable for closing the form. Instead, set the Cycle property of the form (in the Other tab of the Properties window) to Current Record.

    Note: if you close a form in code, acSaveYes will save the design of the form, not the current record. Access saves records automatically. In a multi user environment, saving the design of a form is problematic - if you're the only user at that moment, you will lock out others, otherwise you'll get an error message.

  3. #3
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Close form (A2K SP3)

    Many thanks.

    Tom

Posting Permissions

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