LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Strange issue freezing parent form when unloading a child form

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting Parent Child kcmtnbiker Excel Worksheet Functions 2 March 31st 06 01:54 AM
Excel app as child form in VB.Net mabond Excel Programming 3 September 10th 05 07:25 PM
Unloading a form using the ESC key johncassell[_24_] Excel Programming 2 August 16th 05 06:19 PM
How to avoid re-initialisation when Unloading form count Excel Programming 4 December 14th 04 03:58 PM
Unloading A Form Chrissy[_4_] Excel Programming 1 October 15th 03 02:17 PM


All times are GMT +1. The time now is 03:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"