Backing out of writing a record on a continous form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kcdoell
    New Member
    • Dec 2007
    • 230

    Backing out of writing a record on a continous form

    Back out of writing a record on a continuous form

    I have a continuous form that is displaying records. Once the user drops down to a new record and keys in any character there is no way for the user to stop creating that record. If I have no required fields, it would write a blank record.

    Is there any way to warn a user before the new record line appears (displays) and allow them to cancel the action??

    Thanks,

    Keith.
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    I think you will need to set the forms properties so that a new record cannot be created.
    Then on the form somewhere you provide a button that opens a new form where you can take control of record creation and navigation with well designed VBA.

    Comment

    • kcdoell
      New Member
      • Dec 2007
      • 230

      #3
      Originally posted by Delerna
      I think you will need to set the forms properties so that a new record cannot be created.
      Then on the form somewhere you provide a button that opens a new form where you can take control of record creation and navigation with well designed VBA.

      In the end, somebody told me that if the user hits the esc key on their keyboard it will allow the user to escape. One hit on the esc gets you out of the field and two hits out of the record. Simple solution and it works.....

      Thanks,

      Keith.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32633

        #4
        Check out one of your other threads (After Update Event, cursor jumps from the record in which I made the change to top... ) for ideas on duplicating this behaviour by setting Me.Dirty to FALSE.

        There is also a Before_Update event that you can use to trap the save. Depending on your own criteria, you can decide whether or not to set Cancel=True (cancel the save).

        Comment

        • kcdoell
          New Member
          • Dec 2007
          • 230

          #5
          Originally posted by NeoPa
          Check out one of your other threads (After Update Event, ... ) for ideas on duplicating this behaviour by setting Me.Dirty to FALSE.

          There is also a Before_Update event that you can use to trap the save. Depending on your own criteria, you can decide whether or not to set Cancel=True (cancel the save).
          NeoPa:

          I do have the following code when a new record is created:

          [code=vb]
          Private Sub Form_BeforeUpda te(Cancel As Integer)

          'When a user is creating a new record the following code inserts the MonthID, YearID and
          'The LocationsID. It does a Dlookup for the Locations ID when the control cboLocation is
          'blank.

          If Me.NewRecord Then
          'If cboLocation is Not Null, grab the value from there
          If Not IsNull(frm![cboLocation]).............. ............... ............... ..
          [/code]

          I am thinking that you are saying that I can have a message box display with a OK/Cancel selection that would allow the user to "give" permission for the current record to be written or not to my master table? If so, how would I do that...

          Thanks,

          Keith.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32633

            #6
            I can't tell you how to determine whether or not you want to allow the update to proceed.

            What I can say is that if you determine within your Form_BeforeUpda te procedure, that you don't want it to proceed, you can set the Cancel parameter to TRUE and it will cancel the update.

            Comment

            • kcdoell
              New Member
              • Dec 2007
              • 230

              #7
              so the vb code/command would be :

              [code=vb]
              Cancel=True
              [/code]

              ??

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32633

                #8
                Absolutely. Yes.

                There are many XX_BeforeUpdate (Cancel As Integer) type events. The Cancel parameter is provided as a means to tell the system to abort the action (update; whatever).

                Comment

                • puppydogbuddy
                  Recognized Expert Top Contributor
                  • May 2007
                  • 1923

                  #9
                  Here is an excellent reference source on data validation, including the beforeUpdate event validation that Neopa is addressing.

                  Comment

                  Working...