Results 1 to 6 of 6
  1. #1
    JrMontgom is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Sep 2012
    Location
    Vero Beach, FL USA
    Posts
    124

    How to detect when FORM goes to Design Mode from FOrm Mode

    I want to have a VBA function execute when I have a form go from Form view (CurrentView = 1) to Design view (CurrentView = 0). Can this be done? I want to do this so I can enter data in a table tracking changes to code.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    You want to document when form is manually switched to Design view? I can't find any form event that would be triggered and allow to report that the form is now in Design view.

    I tried Close, Unload, Deactivate. The Debug.Print Me.CurrentView just reports out the 1 constant for Form view.
    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
    InsuranceGuy is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Location
    Colorado
    Posts
    126
    I'm not familiar with an event either. You would need to do this using a helper/hidden form on a timer. Since Access doesn't actually multi-thread, timers can be problematic and I don't usually recommend them on an interactive app. Interesting idea though. If you get it to work effectively, I'd like to learn from you.

    Cheers,


    Jeff

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    I think you'll need to add a temporary Command Button to your Forms, and use it whenever you need to go to Design View, while in development. You can't use CurrentView = 0 to go to Design View, because CurrentView is Read-Only, and but you can use code like this:
    Code:
    Private Sub GoToDesignView_Click()
     'Place your documention code here
     DoCmd.RunCommand acCmdDesignView
    End Sub

    placing your design change documentation in the indicated spot.

    Once development is over, simply remove the button!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    JrMontgom is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Sep 2012
    Location
    Vero Beach, FL USA
    Posts
    124
    Yes the currentview is misleading as it implies you can detect design View but you can't as there is no Event that will allow you to intercept currentview = 0. I now just add code to all my forms to call up a function which captures and posts data to a table for Code Modification.

  6. #6
    keithjen is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    May 2016
    Posts
    1

    Lightbulb Trap Form Design Mode

    I also recently wanted to do this but couldn't find anything on the web to help.

    I managed to do it by creating a blank form called "frmTrapClose".
    On this form I set the "Timer Interval" property to 1000 and added the code below for the "On Timer" event:
    Code:
    Private Sub Form_Timer()
            On Error GoTo Form_Timer_err
            DoEvents
            Sleep (1000)
            DoEvents
            If Forms(Me.OpenArgs).CurrentView = 0 Then
                    ' Put you code here
                    MsgBox "Trapped it"
            End If
    Form_Timer_err:
            DoCmd.Close acForm, Me.Name
    End Sub
    Then at the end of the "ON Close" code for each form in my project (except "frmTrapClose"), I added:
    Code:
    DoCmd.OpenForm "frmTrapClose", , , , , acHidden, Me.Name

    This worked for me I hope it helps others.

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

Similar Threads

  1. Replies: 8
    Last Post: 06-26-2015, 06:00 PM
  2. Replies: 3
    Last Post: 12-01-2014, 07:47 AM
  3. Replies: 4
    Last Post: 11-26-2013, 10:47 AM
  4. Replies: 2
    Last Post: 09-01-2011, 10:48 PM
  5. Replies: 4
    Last Post: 01-14-2011, 10:37 AM

Tags for this Thread

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