VBA Double click from list value

kawi6rr

Registered User.
Local time
Today, 12:34
Joined
Jun 29, 2010
Messages
28
I have a report that I want to run from a double click off a list view. The message box shows the correct value when double clicking but when the report pops up it only goes to the first record. It does not go to the record I've that column(0) is assigned to.

Private Sub lstOne_DblClick(Cancel As Integer)
Dim strWhere As String
strWhere = Me.lstOne.Column(0)
DoCmd.OpenReport "rptMemberSummary", acViewPreview, , strWhere

MsgBox strWhere
End Sub

Thanks in advance for any help.
 
You need to specify the name of the field too:
Code:
Private Sub lstOne_DblClick(Cancel As Integer)
Dim strWhere As String
   strWhere = [B][COLOR=red]"[FieldName]=" & [/COLOR][/B]Me.lstOne.Column(0)
   DoCmd.OpenReport "rptMemberSummary", acViewPreview, , strWhere
   MsgBox strWhere
End Sub

If it is text you need quotes too:

Code:
Private Sub lstOne_DblClick(Cancel As Integer)
Dim strWhere As String
   strWhere = [B][COLOR=red]"[FieldName]=" & Chr(34) & [/COLOR][/B]Me.lstOne.Column(0) [B][COLOR=red]& Chr(34)[/COLOR][/B]
   DoCmd.OpenReport "rptMemberSummary", acViewPreview, , strWhere
   MsgBox strWhere
End Sub
 
Solved! Thanks bob you're a life saver.
 

Users who are viewing this thread

Back
Top Bottom