Results 1 to 6 of 6
  1. #1
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664

    Private Sub Form_Current use

    There is a tutorial on the web that states to start editing a form, one should add button on our form and name it btn_Edit.
    Also give the button a caption Edit.

    Put it under events in the property sheet for OnClick.



    The initial code shown would be


    Code:
    Private sub btn_Edit_Onclick()
    
    Me.AllowEdits=True
    
    End Sub
    Easy enough.

    Now a subprogram to disallow edits whenever the user moves to the next record.

    Code:
    Private sub Form_Current()
    
     Me.AllowEdits=False
    
    End Sub

    Again thus us very straight forward.


    That is the point of my question. I am not sure what this last subprogram does. It disallows edits.

    But where does it disallow edits?

    I am just not sure what the second subprogram does and how it does it.

    Any help appreciated. Thanks in advance.


    Respectfully,


    Lou Reed
    Last edited by Lou_Reed; 01-20-2017 at 08:41 AM. Reason: correction

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2013
    Join Date
    Nov 2009
    Posts
    2,392
    The stop-edit event occurs when one changes record. That is the definition of the Current event.

    I myself do not recommend this approach of pre-locking a form. It locks the drop down selectors - which is one problem.

  3. #3
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    If the tutorial is showing the code just as you posted it, find another tutorial. Neither one of those subs will run when you think they do - they are not named correctly.

    The first should be btn_Edit_Click(), and the second should be Form_Current(). Turning the edits off would not usually be done in response to a button click.

  4. #4
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Okay, I have made some corrections. I believe that the sub programs are now correct.
    I changed the edit_Form_Current() to Form_Current(). The original as written was incorrect.

    My question is what triggers this action? I mean we know when editing of a record is enabled; when the button labeled edit is clicked.

    But when is Form_Current() enabled?

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

  5. #5
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    You can't enable/disable events - they always happen. Whether or not you have a procedure for any particular event is up to you and depends on what your needs are.

    The Form_Current event happens whenever you move to a another record on a form, whether it's a new or an existing record. If you need to take different actions depending on whether it is a new record or not, use the Me.Newrecord property (True if you are on a new record)

  6. #6
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,446

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Form_Current doesn't fire when moving to first record.
    By MatthewGrace in forum Programming
    Replies: 14
    Last Post: 01-09-2019, 04:09 PM
  2. Combining Private Sub
    By Thompyt in forum Programming
    Replies: 2
    Last Post: 11-11-2014, 02:25 PM
  3. Form_Current() running multiple times
    By caddcop in forum Forms
    Replies: 0
    Last Post: 04-01-2011, 09:00 AM
  4. Form_Current Event
    By Bubi in forum Forms
    Replies: 6
    Last Post: 02-22-2011, 11:16 AM
  5. form_current event question
    By edo in forum Forms
    Replies: 0
    Last Post: 09-08-2008, 02:54 PM

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