D
DocBrown
Can someone explain to me the following:
I have a Listbox on a form. I set the GotFocus property to [Event Procedure]
and then define a function. Do the same for LostFocus:
Private Sub cboSchoolNameSelect_LostFocus()
Listbox_Hght (False)
End Sub
Private Sub cboSchoolNameSelect_GotFocus()
Listbox_Hght (True)
End Sub
Public Sub Listbox_Hght(big As Boolean)
Dim myHeight As Long, myCount As Long
Dim myCurrCtrl As ListBox
Set myCurrCtrl = Me.ActiveControl
myHeight = myCurrCtrl.Height
myCount = myCurrCtrl.ListCount
If myCount > 5 Then
myCount = 5
End If
If myCount <= 0 Then
myCount = 1
End If
If big Then
myCurrCtrl.Height = myHeight * myCount
Else
myCurrCtrl.Height = myHeight / myCount
End If
'Debug.Print "Listbox_Hght: " & Str(myCount) & Str(myHeight)
End Sub
This function changes the height of the list box when it gets focus and
returns it to it's original height when focus is lost. I'm doing this because
I want the listbox height to be one line until the user clicks on it.
This works as expected. But then I change the GotFocus and LostFocus
properties to the following
GotFocus: =Listbox_Hght(True)
LostFocus: =Listbox_Hght(False)
This doesn't work because the function is called twice when I click in the
box and twice again with I click out of the box.
What's going on?? (Yes, I disabled the call in the *_GotFocus and
*_LostFocus calls as I was testing this.)
Thanks,
John S.
I have a Listbox on a form. I set the GotFocus property to [Event Procedure]
and then define a function. Do the same for LostFocus:
Private Sub cboSchoolNameSelect_LostFocus()
Listbox_Hght (False)
End Sub
Private Sub cboSchoolNameSelect_GotFocus()
Listbox_Hght (True)
End Sub
Public Sub Listbox_Hght(big As Boolean)
Dim myHeight As Long, myCount As Long
Dim myCurrCtrl As ListBox
Set myCurrCtrl = Me.ActiveControl
myHeight = myCurrCtrl.Height
myCount = myCurrCtrl.ListCount
If myCount > 5 Then
myCount = 5
End If
If myCount <= 0 Then
myCount = 1
End If
If big Then
myCurrCtrl.Height = myHeight * myCount
Else
myCurrCtrl.Height = myHeight / myCount
End If
'Debug.Print "Listbox_Hght: " & Str(myCount) & Str(myHeight)
End Sub
This function changes the height of the list box when it gets focus and
returns it to it's original height when focus is lost. I'm doing this because
I want the listbox height to be one line until the user clicks on it.
This works as expected. But then I change the GotFocus and LostFocus
properties to the following
GotFocus: =Listbox_Hght(True)
LostFocus: =Listbox_Hght(False)
This doesn't work because the function is called twice when I click in the
box and twice again with I click out of the box.
What's going on?? (Yes, I disabled the call in the *_GotFocus and
*_LostFocus calls as I was testing this.)
Thanks,
John S.