Page 2 of 2 FirstFirst 12
Results 16 to 24 of 24
  1. #16
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    The 'save' button should simply initiate the save and nothing else. No Messagebox, nothing except initiate the save. Once that is clicked, execution will go to the Form_BeforeUpdate event, and the Messagebox will then pop up, making sure that the user actually wants to save the Record and hasn't hit the button by mistake.

    For the 'save' button you can simply use

    DoCmd.RunCommand acCmdSaveRecord



    Linq ;0)>

  2. #17
    james28 is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2014
    Posts
    92
    Quote Originally Posted by Missinglinq View Post
    The 'save' button should simply initiate the save and nothing else. No Messagebox, nothing except initiate the save. Once that is clicked, execution will go to the Form_BeforeUpdate event, and the Messagebox will then pop up, making sure that the user actually wants to save the Record and hasn't hit the button by mistake.

    For the 'save' button you can simply use

    DoCmd.RunCommand acCmdSaveRecord

    Linq ;0)>


    Thank you for the explanation! If I am understanding correctly, my save button is actually still functioning just fine. The issue is that the Form_BeforeUpdate event fires after clicking save, which then makes the message show up.


    The save command that you suggested is actually what I am currently using in my form.


    Do you know of any way to add a condition or some other stop, so that users are not given the popup option when they click the save button?

    Thank you again!

  3. #18
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I suggested an approach in post 8.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #19
    james28 is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2014
    Posts
    92
    June,

    Thank you for the reply. Sorry that I missed that! That sounds exactly like what I am trying to do. Unfortunately, I have no idea where to begin to do that. Do you happen to have a tutorial or sample that you could guide me with?


    Thank you again!

  5. #20
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Are you interested in the suggestion to use Boolean variable declared in module header? I never actually used that approach. What exactly do you not understand about the suggestion? How to declare variable in module header? How to set the variable? How to reference it in BeforeUpdate event?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #21
    james28 is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2014
    Posts
    92
    June,

    Thank you for the reply. Unfortunately, I have no experience in doing any of what you said. Any examples or tutorials would be greatly appreciated.

    Thank you!

  7. #22
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    You show posts with VBA code you implemented. Exactly where are you lost? I really don't want to reproduce a tutorial in a forum thread. If you lack basic knowledge of programming concepts, VBA language, Access functionality - that is way too much to cover here.

    The suggestion I offer will involve maybe 5 lines of code.

    1. declare a Boolean variable in the form code module header
    Dim booSave As Boolean

    2. reference the variable in appropriate events
    In the Save/Close button Click:
    booSave = True
    In the BeforeUpdate:
    If booSave = True Then
    'do this
    Else
    'do this
    End If
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #23
    james28 is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2014
    Posts
    92
    June,

    Thank you for the reply and the patience. I really appreciate it. I certainly am no expert in any of the things that you mentioned, but I am learning.

    As much as I would like to take credit for the code I posted before, it was not originally mine.




    In your example, I understand what to do for #2. I simply replace my code in the Form_BeforeUpdate with what you have (replacing the do this).

    I am not so sure what to do with step 1. I think it may have to do with my lack of terminology.


    Are you saying that the "form code module header" is the name of the area between Private Sub Form_BeforeUpdate(Cancel As Integer) and what you have in #2?


    By that I mean, the entire thing should look like:



    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
    Dim booSave As Boolean
    booSave = True
    In the BeforeUpdate:
    If booSave = True Then
    'do this
    Else
    'do this
    End If


    If that is not what you were saying, I do not know where the "form code module header" is. I found reference to a FormHeader and an Auto_Header0, but nothing specifically called "module header".



    Thank you again!

  9. #24
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    No, the header is at the top of the module before any procedure code

    Option Compare Database
    Option Explicit
    Dim booSave As Boolean

    Private Sub Save_Click()
    booSave = True
    DoCmd.RunCommand acCmdSaveRecord
    End Sub

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    If booSave = True Then
    'run this code
    booSave = False
    Else
    Cancel = True
    End If
    End Sub
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Master\Detail Only Show Last Detail Record
    By jamies in forum Queries
    Replies: 2
    Last Post: 04-14-2014, 01:25 PM
  2. Replies: 6
    Last Post: 11-18-2012, 12:54 PM
  3. Master/detail form problem....
    By dkperez in forum Forms
    Replies: 5
    Last Post: 04-01-2011, 04:28 PM
  4. Master Detail Web Form - Access 2010.
    By Robeen in forum Forms
    Replies: 2
    Last Post: 03-21-2011, 02:34 PM
  5. Enable button in the master form when clicking in the detail
    By DistillingAccess in forum Programming
    Replies: 8
    Last Post: 08-03-2010, 10:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums