Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This is quite complex, but I cannot simplify further...
I programmed 2 cascading forms. The first one is to list GroupKeys and has a Modify button. When the user selects a GroupKey and clicks the Modify button, then the second form shows up and allows the user to edit the selected GroupKey. The user can alternatively double-click on any listed GroupKey in order to edit it. The first form (frmGroupKeys) has a listbox and the Modify button. The second (frmGroupKey) has a couple of textboxes and the OK button. (I include below handlers of the double-click event on the listbox, of the initialize event of the frmGroupKey form, and of the click event of the OK button) THE ISSUE: When the user edits a GroupKey by double-clicking on the listbox, then the frmGroupKeys form remains disabled, even after the frmGroupKey form is unloaded! Interesting is that when the user edits a GroupKey using the Modify button, then form frmGroupKeys gets back to "enabled" when frmGroupKey is unloaded. I suspect that the listbox object is considered as the parent of the frmGroupKey window, while the "entire" frmGroupKeys should be the one to be enabled instead of just the listbox. I think it's a problem with the implementation of the listbox as VBA class. Can someone tell me if this is experienced somewhere else (I run WinXP). Thank you and have a nice day. Stefano Gatto Geneva, Switzerland Form frmGroupKeys: Private Sub lstGroupKeys_DblClick(ByVal Cancel As MSForms.ReturnBoolean) btnModify_Click End Sub Form frmGroupKeys: Private Sub btnModify_Click() If lstGroupKeys.ListIndex = -1 Then Exit Sub If lstGroupKeys.List(lstGroupKeys.ListIndex, 0) = gstrGroupKeyNotDefined Then MsgBox "This Group Key cannot be modified.", vbCritical + vbOKOnly, "Error Modifying Group Key" Exit Sub End If gstrCaller = "Modify" frmGroupKey.Show End Sub Form frmGroupKey: Private Sub UserForm_Initialize() Dim rngRegion As Range Dim rngCell As Range Set rngRegion = ThisWorkbook.Worksheets("Region").Range("Region") If rngRegion.Rows.Count 2 Then Set rngRegion = rngRegion.Offset(1, 0).Resize(rngRegion.Rows.Count - 2, 1) For Each rngCell In rngRegion cmbRegion.AddItem rngCell.Value Next rngCell End If If gstrCaller = "Modify" Then txtGroupKey.Value = frmGroupKeys.lstGroupKeys.List(frmGroupKeys.lstGro upKeys.ListIndex, 0) cmbRegion.Value = frmGroupKeys.lstGroupKeys.List(frmGroupKeys.lstGro upKeys.ListIndex, 1) End If End Sub Form frmGroupKey: Private Sub btnOK_Click() Dim rngGroupKey As Range Dim rngCell As Range Dim inti As Integer txtGroupKey.Value = Trim(txtGroupKey.Value) If txtGroupKey.Value = "" Or cmbRegion.Value = "" Then MsgBox "Please enter a valid Country and Region before saving.", vbCritical + vbOKOnly txtGroupKey.SetFocus Exit Sub End If Set rngGroupKey = ThisWorkbook.Worksheets("GroupKey").Range("GroupKe y") If gstrCaller = "New" Then Set rngGroupKey = rngGroupKey.Offset(rngGroupKey.Rows.Count - 1).Resize(1, 2) rngGroupKey.Insert Shift:=xlDown rngGroupKey.Offset(-1).Cells(1, 1).Value = txtGroupKey.Value rngGroupKey.Offset(-1).Cells(1, 2).Value = cmbRegion.Value gblnNeedsSaving = True ElseIf gstrCaller = "Modify" Then For Each rngCell In rngGroupKey.Offset(1).Resize(rngGroupKey.Rows.Coun t - 2, 1) If rngCell.Value = frmGroupKeys.lstGroupKeys.List(frmGroupKeys.lstGro upKeys.ListIndex, 0) Then rngCell.Value = txtGroupKey.Value rngCell.Offset(0, 1).Value = cmbRegion.Value gblnNeedsSaving = True Exit For End If Next rngCell End If 'updating customers table, since this table duplicates Region. UpdateCustomersRegion txtGroupKey.Value, cmbRegion.Value frmGroupKeys.SortGroupKeys frmGroupKeys.FillGroupKeys txtGroupKey.Value Unload Me End Sub I can email the workbook to whoever is so kind to help me. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Sorting Parent Child | Excel Worksheet Functions | |||
Excel app as child form in VB.Net | Excel Programming | |||
Unloading a form using the ESC key | Excel Programming | |||
How to avoid re-initialisation when Unloading form | Excel Programming | |||
Unloading A Form | Excel Programming |