Results 1 to 6 of 6
  1. #1
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Prevent user from exiting a form (2000)

    Hi,
    I have a main form titled FrmMain, and a sub form, FrmPayments.

    The user records a payment relating to the record in form Main within FrmPayments. Claims are sent it, and then this is agreed or disagreed.

    I have a 2 essential fields, DateSent and Estimate. Both of these are within FrmPayments. If DateSent is >0 then the person is sent to Estimate to record an amount agreed.

    This is the code:

    <hr>Private Sub DateSent_AfterUpdate()
    If IsNull(Me.Estimate) Then
    Me.Estimate.SetFocus
    End If


    End Sub

    Private Sub Estimate_AfterUpdate()
    If Me.Estimate > 0 And Me.Comments = "Await GFC" Then
    Me.Comments = Null
    End If
    If IsNull(Me.Estimate) And Me.DateSent > 0 Then
    MsgBox "If this fee is being sent to Service Centre, then you must record an amount in estimate", vbInformation, "Error"
    Me.Estimate.SetFocus
    Exit Sub
    End If

    End Sub<hr>

    On the main form there is a combobox, where the user can select a record in the database to go to. A certain employee is using this to exit the record in FrmPayment.

    The coding above doesn't seem to be able to stop this. Any ideas?

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

    Re: Prevent user from exiting a form (2000)

    You can make DateSent and Estimate required fields in the underlying table. The user won't be able to save a record if either of the two is null.

  3. #3
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Prevent user from exiting a form (2000)

    Will this be possible to do this in coding.
    Essentially what I need is that if there is a date in DateSent then there has to be a figure in Estimate.
    However, there can be a figure in Estimate but not anything in DateSent.
    This is solely because at the end of each month we manually estimate all outstanding payments where a claim hasn't been received.
    When a date is in DateSent, this means that we have sent the payment off to Finance to be paid. But this still remains as an estimated figure until we have confirmation from Finance that it has been paid.
    Think that makes sense........

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

    Re: Prevent user from exiting a form (2000)

    I'm confused. Do you mean that initially, the user can enter a date in DateSent but leave Estimate blank? And at a later moment, you want to make sure that all Estimates have been filled in if DateSent has been entered? Or am I completely off?

  5. #5
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Prevent user from exiting a form (2000)

    No, there are 2 things that the user is able to do.
    If the User fills in DateSent, then there has to be a figure in Estimate.
    If the User fills in Estimate, but not DateSent, then this is fine. This means that the user is estimating the payment, but has not yet received a claim.

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

    Re: Prevent user from exiting a form (2000)

    You should still be able to do this without coding.
    Open the table in design view.
    Activate the Properties window.
    In the Validation Rule property, enter

    [DateSent] Is Null Or [Estimate] Is Not Null

    and in the Validation Text property, enter the text to be displayed if the user forgets to enter an Estimate after filling in DateSent.

Posting Permissions

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