desjardins
Registered User.
- Local time
- Today, 13:54
- Joined
- Dec 21, 2010
- Messages
- 13
Hi,
I have a form where people can enter new employees. If they enter in a last name that matches a current employee, I have a pop-up form asking them to check for duplicates. There is a listbox on this form that contains possible duplicates, for example
Jane Smith
Joe Smith
Bob Smith
What I want is for them to be able to choose "Joe Smith" from the listbox and have the main form (frm_checklist) populate with Joe Smith's information so they can edit it.
Here is my code for the command button:
Here's what is happening:
1. When the possible duplicate last name is entered, the duplicates form pops up with the correct list of names.
2. When I choose a name from the listbox and click on the select button (cmd_choose) the pop-up form is supposed to close and return me to that person's record on the main form. But I get a message saying "Open form was canceled" and the pop-up form does not close.
Thanks in advance, y'all have been very helpful to me so far.
I have a form where people can enter new employees. If they enter in a last name that matches a current employee, I have a pop-up form asking them to check for duplicates. There is a listbox on this form that contains possible duplicates, for example
Jane Smith
Joe Smith
Bob Smith
What I want is for them to be able to choose "Joe Smith" from the listbox and have the main form (frm_checklist) populate with Joe Smith's information so they can edit it.
Here is my code for the command button:
Code:
Private Sub cmd_choose_Click()
On Error GoTo Err_cmd_choose_Click
Dim strSelection As String, varItem As Variant
Dim strSQL As String
For Each varItem In Me.list_choose.ItemsSelected
strSelection = strSelection & Me.list_choose.ItemData(varItem) & ","
Next
strSelection = Left(strSelection, Len(strSelection) - 1)
strSQL = "tbl_employees.PersonID = (" & strSelection & ")"
' open the checklist form for the selected person
DoCmd.OpenForm "frm_checklist", acNormal, , strSQL, acFormEdit, acWindowNormal, ""
DoCmd.Close acForm, "frm_duplicates"
Exit_cmd_choose_Click:
Exit Sub
Err_cmd_choose_Click:
MsgBox Err.Description
Resume Exit_cmd_choose_Click
End Sub
Here's what is happening:
1. When the possible duplicate last name is entered, the duplicates form pops up with the correct list of names.
2. When I choose a name from the listbox and click on the select button (cmd_choose) the pop-up form is supposed to close and return me to that person's record on the main form. But I get a message saying "Open form was canceled" and the pop-up form does not close.
Thanks in advance, y'all have been very helpful to me so far.