Hi,
I'm trying to get a report filtered and displayed inside a navigationform, using docmd.browseto to open the report. This report's recordset is a query and has a filed named donID (the ID number of a donor) to sort several donors. I'm using a listbox "lDonFil" to choose one or many donors.
If I filter with a combo box only one value, goes fine, the problem is when I try to put a string in the Where condition. It doesn't even work when I only choose one criteria (by only selecting one row in the lisbox lDonFil".
Does anyone have any idea where is the error? The code is bellow. I've tried several ways, with brackets, without brackets, etc...
Private Sub fltDonor_Click()
Dim ctlSource As Control
Dim strDonId As String
Dim intCurrentRow As Integer
Set ctlSource = Me.lDonFil
For intCurrentRow = 0 To ctlSource.ListCount - 1
If ctlSource.Selected(intCurrentRow) Then
strDonId = strDonId & ctlSource.Column(0, intCurrentRow) & " OR_
[DonId]="
End If
Next intCurrentRow
If Len(strDonId) < 13 Then
strDonId = ""
Else
strDonId = "[DonID]=" & Left(strDonId, Len(strDonId) - 12)
End If
DoCmd.BrowseTo acReport, "rDonor", "nmain.nmainsub>nreports.nreportprj>fparadonor.rparadonor", "strDonId", "",_ acFormReadOnly
End Sub
Thanks a lot if anyone can help
I'm trying to get a report filtered and displayed inside a navigationform, using docmd.browseto to open the report. This report's recordset is a query and has a filed named donID (the ID number of a donor) to sort several donors. I'm using a listbox "lDonFil" to choose one or many donors.
If I filter with a combo box only one value, goes fine, the problem is when I try to put a string in the Where condition. It doesn't even work when I only choose one criteria (by only selecting one row in the lisbox lDonFil".
Does anyone have any idea where is the error? The code is bellow. I've tried several ways, with brackets, without brackets, etc...
Private Sub fltDonor_Click()
Dim ctlSource As Control
Dim strDonId As String
Dim intCurrentRow As Integer
Set ctlSource = Me.lDonFil
For intCurrentRow = 0 To ctlSource.ListCount - 1
If ctlSource.Selected(intCurrentRow) Then
strDonId = strDonId & ctlSource.Column(0, intCurrentRow) & " OR_
[DonId]="
End If
Next intCurrentRow
If Len(strDonId) < 13 Then
strDonId = ""
Else
strDonId = "[DonID]=" & Left(strDonId, Len(strDonId) - 12)
End If
DoCmd.BrowseTo acReport, "rDonor", "nmain.nmainsub>nreports.nreportprj>fparadonor.rparadonor", "strDonId", "",_ acFormReadOnly
End Sub
Thanks a lot if anyone can help