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.
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.
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.
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
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
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.
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:
Then at the end of the "ON Close" code for each form in my project (except "frmTrapClose"), I added: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
Code:DoCmd.OpenForm "frmTrapClose", , , , , acHidden, Me.Name
This worked for me I hope it helps others.