Results 1 to 4 of 4
  1. #1
    Benaal is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2014
    Posts
    6

    How to detect the Add/Edit/read Only mode a form is open in?

    Hi all,



    I have a main menu form, containing a list of widgets and two buttons, Add and Edit. I have used the Macro Builder to link each of the buttons to the CRUD form behind. On the CRUD form, there are data input boxes for all properties of the selected widget, plus a Delete button. However, I only want that Delete button to be active in the Edit mode, not the Add mode. Using the onGotFocus event of the CRUD form, how would I go about detecting the add/edit/read-only state, in order to enable or disable the delete button?

    Thanks in advance,

    Martin

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    What I do is pass a parameter to the form when I open it.

    DoCmd.OpenForm "form name", , , , acFormEdit, , "edit"

    Code in the form open event sets button state depending on the parameter:

    Sub formname_Open(Cancel As Integer)
    Me.buttonname.Visible = (Me.OpenArgs = "edit")
    End Sub

    Or maybe:

    If Forms!formname.AllowEdits = True Then
    ...

    However, this might not help you because a form that is set to allow edits may also be allowed to set additions. So unless you open a form set to only one mode and exclude all others, they could all be valid - except DataEntry. DataEntry negates the Allow_ properties.
    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.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    If the user Clicks the Edit button, can you not use that Event to set the Visible property of the DELETE button??

  4. #4
    Benaal is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2014
    Posts
    6
    Ok, i've solved my issue.

    I detect on Form_Load event the state of me.dataentry

    If it is true then the form has been opened in Add mode. If not, it has been opened in Edit mode.

    Hope this helps someone in the future.

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

Similar Threads

  1. Replies: 9
    Last Post: 10-17-2012, 11:37 AM
  2. Change form to edit mode using VBA
    By Richie27 in forum Programming
    Replies: 1
    Last Post: 06-05-2012, 04:39 AM
  3. Open Access Database in Read Only Mode
    By praloy in forum Programming
    Replies: 2
    Last Post: 03-28-2012, 10:50 PM
  4. Replies: 1
    Last Post: 12-04-2011, 09:11 PM
  5. Replies: 2
    Last Post: 09-01-2011, 10:48 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