I have a list box (In a pop up form) where I can select a record and open it in the management form for viewing / editing / etc.
Below is the code thats works for the double click event (on the list box) and a command button I've added to the form.
But when I press enter on a record in the list box I get run-time error 2585 and in debug the high-light line is my DoCmd.close? Its strange that it works for the other but not the 'enter' I tried adding DoEvents after looking through some previous posts but I'm not sure if I've used it correctly?
Below is the code thats works for the double click event (on the list box) and a command button I've added to the form.
Code:
Dim strWhere As String
If Me!List_All_Contacts.ItemsSelected.Count = 0 Then Exit Sub
For Each varItem In Me!List_All_Contacts.ItemsSelected
strWhere = strWhere & Me!List_All_Contacts.Column(4, varItem) & ","
Next varItem
strWhere = Left$(strWhere, Len(strWhere) - 1)
strWhere = "[C_ID] IN (" & strWhere & ")"
DoEvents
DoCmd.OpenForm FormName:="frm_Contacts_Mgt", WhereCondition:=strWhere, DataMode:=acFormReadOnly
DoCmd.Close acForm, Me.Name '*** line which debug highlists ***
Forms!frm_Contacts_Mgt.SetFocus
But when I press enter on a record in the list box I get run-time error 2585 and in debug the high-light line is my DoCmd.close? Its strange that it works for the other but not the 'enter' I tried adding DoEvents after looking through some previous posts but I'm not sure if I've used it correctly?