Treeview behaves differently when clicked than when clicked

Situation: I have db Access 2010, which is designed to be deployed on a Windows 8 tablet. The main form of the application contains a Treeview control. Selecting a node in Treeview sets the visibility of one of several subforms that are used to view / edit the details of the selected node element. I have a yes / no message box and some basic BeforeUpdate event code for each of the subforms. Therefore, when the record on the subform is dirty and the user clicks anywhere in the main form (including anywhere in the Treeview control), this code is run.

Problem: When a sub-format entry is dirty and the user deletes all Treeview controls, a message box appears, but you cannot interact with it because the application is busy. Performing what I do not know, but it remains so until Access is closed through the task manager. There is no code associated with anything for Treeview other than the Click event. This happens even when they touch the space in the Treeview below existing nodes.

If the recording is not dirty, everything works fine.

If the record is dirty and the user clicks the "Save" button on the subform to trigger the BeforeUpdate event, everything works fine.

If the user removes another control or in the empty space of the main form, the BeforeUpdate event is fired and everything works fine.

If you connect the mouse to the tablet and follow the same sequence of steps, clicking instead of clicking, everything will be fine.

I spent a lot of effort on the search and could not find anything related to this, so any suggestions or recommendations in new places to search for proposals would be deeply appreciated.

I have attached the sample code BeforeUpdate that exists in each of these subforms. It's pretty simple, but maybe there's something in it that clicks and Treeviews just don't like.

Private Sub Form_BeforeUpdate(Cancel As Integer) 'If the form data has changed a message is shown asking if 'the changes should be saved. If the answer is no then 'the changes are undone On Error GoTo BeforeUpdate_Error If Me.Dirty Then 'Add PropertyID, LPParentNodeID and TreeNodeID if Record is new If Me.NewRecord Then Me.PropertyID = Me.Parent!PropertyID Me.LPParentNodeID = Me.Parent!txtCurrKey Me.TreeNodeID = DateDiff("s", Date, Now()) End If 'Display prompt to save the record If MsgBox("The record has changed - do you want to save it?", _ vbYesNo + vbQuestion, "Save Changes") = vbNo Then Me.Undo End If End If 'If the record is still dirty, then record the change in the Audit table If Me.Dirty Then Call AuditTrail(Me, InstanceID, PropertyID) End If BeforeUpdate_Exit: Exit Sub BeforeUpdate_Error: MsgBox Err.Description Resume BeforeUpdate_Exit End Sub 

08/30/2013 Update: I forgot to mention the debugging behavior in the original question. When I set a breakpoint on the Subform SubUpdate subform on any line from the actual Sub entry point to the If statement with a message field, a code window appears, but the application becomes busy again, and I cannot interact with either the window. As before, this behavior is unique in order to use this damned Treeview control.

+4
source share
1 answer

What you can do is put some kind of editing / saving structure in each of the subforms, in which the controls in the subordinate form are locked until the right button is pressed, and will be locked after clicking the "Save" button. So:

 private sub bEdit() editMode true end sub private sub bSave() ...save logic editMode false end sub private sub editMode(isEdit as boolean) dim ctl as control for each ctl in me.controls if ctl.controltype is actextbox or ctl.controltype is accombobox then ctl.locked = (not isEdit) end if next end sub 

With this approach, then the small task is to add an editmode control for the parent form by adding

 me.parent.editmode isEdit 

until the end of the editing procedure.

In the parent form, editMode must be a sub-item of PUBLIC.

In this submenu, control whether the tree will do anything when pressed:

 public sub editMode(isEdit as boolean) tree.enabled = (not isEdit) end sub 
+1
source

Source: https://habr.com/ru/post/1499703/


All Articles