I need help here...
I have created a list box (LstCName) from a form named (contactlist) that picks up employee names from a query named (lkpcontacts). The employee names are displayed fine but when i click on a name, i want it to take me to that persons details which are stored in (frmcontacts). At the moment it's not doing it... can you help.
Private Sub LstCName_DblCli ck(Cancel As Integer)
' Double-clicking a name is the same as choosing the name
' and then clicking the edit button.
cmdSome_Click
End Sub
Private Sub cmdSome_Click()
Dim strWhere As String, varItem As Variant
' Request to edit items selected in the list box
' If no items selected, then nothing to do
If Me!LstCName.Ite msSelected.Coun t = 0 Then Exit Sub
' Loop through the items selected collection
For Each varItem In Me!LstCName.Ite msSelected
' Grab the ContactID column for each selected item
strWhere = strWhere & Me!LstCName.Col umn(0, varItem) & ","
Next varItem
' Throw away the extra comma on the "IN" string
strWhere = Left$(strWhere, Len(strWhere) - 1)
' Open the contacts form filtered on the selected contacts
strWhere = "[ContactID] IN (" & strWhere & ") "
DoCmd.OpenForm FormName:="frmC ontacts", WhereCondition: =strWhere
DoCmd.Close acForm, Me.Name
End Sub
I have created a list box (LstCName) from a form named (contactlist) that picks up employee names from a query named (lkpcontacts). The employee names are displayed fine but when i click on a name, i want it to take me to that persons details which are stored in (frmcontacts). At the moment it's not doing it... can you help.
Private Sub LstCName_DblCli ck(Cancel As Integer)
' Double-clicking a name is the same as choosing the name
' and then clicking the edit button.
cmdSome_Click
End Sub
Private Sub cmdSome_Click()
Dim strWhere As String, varItem As Variant
' Request to edit items selected in the list box
' If no items selected, then nothing to do
If Me!LstCName.Ite msSelected.Coun t = 0 Then Exit Sub
' Loop through the items selected collection
For Each varItem In Me!LstCName.Ite msSelected
' Grab the ContactID column for each selected item
strWhere = strWhere & Me!LstCName.Col umn(0, varItem) & ","
Next varItem
' Throw away the extra comma on the "IN" string
strWhere = Left$(strWhere, Len(strWhere) - 1)
' Open the contacts form filtered on the selected contacts
strWhere = "[ContactID] IN (" & strWhere & ") "
DoCmd.OpenForm FormName:="frmC ontacts", WhereCondition: =strWhere
DoCmd.Close acForm, Me.Name
End Sub
Comment