I get an "Invalid Procedure Call or Argrument " error when I try to set my combo box to show a default user, and then as the code tries to set the focus to a textbox (a password text) on the same form.
After I close the error message, my form does have the correct User shown in in the ComboBox. Interestingly, the user name is highlighted.
Doing Something Wrong -- Stumped.
After I close the error message, my form does have the correct User shown in in the ComboBox. Interestingly, the user name is highlighted.
Doing Something Wrong -- Stumped.
Code:
Private Sub PopulateCboUserName()
'<EhHeader>
'On Error GoTo PopulateCboUserName_Err
'</EhHeader>
102 With cboUserName
104 Do Until adoRecordset.EOF
106 .AddItem adoRecordset![User Name]
108 adoRecordset.MoveNext
Loop
'show the name of the default user in the cboUserName
112 .ListIndex = LF_GetListIndex(cboUserName, g_str_DefaultUser)
End With
114 Set adoRecordset = Nothing
'<EhFooter>
Exit Sub
PopulateCboUserName_Err:
MsgBox Err.Description & vbCrLf & _
"in xGELv2.frmStart.PopulateCboUserName " & _
"at line " & Erl
Resume Next
'</EhFooter>
End Sub
Private Sub cboUserName_Click()
110 txtPassword = ""
'I did some more drilling down and this is the statement that raises the error.
' This "cboUserName_Click" automatically happens after the PopulateCboUserName executes
txtPassword.SetFocus
End Sub
Function LF_GetListIndex(Combo As ComboBox, S$) As Integer
Dim L9&
For L9 = 0 To Combo.ListCount - 1
If S$ = Combo.List(L9) Then
LF_GetListIndex = L9
Exit Function
End If
Next
LF_GetListIndex = -1
End Function