Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003

    Unanswered: interupt save from record selector

    I have a form that i want to run logging on, the form has a navigation strip, so if you got to add new from there, it will automaticly add a record, i want to cancel that and make sure the user has to click my save button, how can i do this?
    Last edited by mikezx10; 11-19-07 at 11:31.

  2. #2
    Join Date
    Nov 2003
    The only reason to select a Save would be if the user actually entered or modified a record. With that in mind, you could do this:

    Delcare a Variable in the declarations section of your Form (under Option Explicit). Let's call it ByPass

    Dim ByPass As Integer

    This will make the variable Public to all Code in that Form only.

    In your Save button's OnClick event, enter this line:

    ByPass = 1

    This will indicate to to any code in Form that the Save button WAS selected.

    Now in the Form's BeforeUpdate event, Copy and paste this:

       'Check the ByPass integer variable. If it contains 1 then reset it
       'to 0 and skip the Dirty check since we now that the Save button
       'was selected.
       If ByPass = 1 Then ByPass = 0: Exit Sub
       'If someone has edited anywhere within the record then the Form's
       'Dirty property becomes True. If we read this property we can then
       'therefore determine that changes of sorts have been made and we 
       'now want the User to Select the Save button. Let's inform them of 
       'Check the Form's Dirty property...
       If Me.Dirty = True Then
          'Because we know the ByPass variable is 0 (since we managed
          'to get this far) let's inform the User to select the Save Button.
          MsgBox "You have made changes to this record. Please select" & vbCr & _
                 "the save button before moving on. Thank You.", vbExclamation, _
                 "Please Select Save Button"
          'Cancel the Form from moving off record.
          Cancel = True
       End If
    Sumthin like that....

    Self Taught In ALL Environments.....And It Shows!

  3. #3
    Join Date
    Oct 2003
    very nice thanks!

Posting Permissions

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