show select records in report

  • Thread starter Thread starter Cuda
  • Start date Start date
C

Cuda

Shows every record:
Private Sub Report_Open(Cancel As Integer)
Dim stDocName As String
Dim strInvoicing As String
Dim strSites As String

strInvoicing = "InvPercent"
strSites = "Base List.Subform!SiteComplete"

Shows one page of report but fields are blank....
Private Sub Report_Open(Cancel As Integer)
Dim stDocName As String
Dim strInvoicing As String
Dim strSites As String

strInvoicing = "InvPercent"
strSites = "Base List.Subform!SiteComplete"

stDocName = "Open Projects"
DoCmd.OpenReport stDocName, acPreview, wherecondition:=strInvoicing &
strSites = "<1"
End Sub


stDocName = "Open Projects"
DoCmd.OpenReport stDocName, acPreview, wherecondition:=strInvoicing <= 1
& strSites <= 1
End Sub
 
Don't follow what you are doing. You're trying to open a report in its Open
event, i.e. while it's already opening?

Are you trying to filter the report? If so, some alternatives:
a) Use another event (such as the Click of a command button on a form) to
open the report with a WhereConditon. Examples:
http://allenbrowne.com/casu-15.html
http://allenbrowne.com/casu-08.html

b) Set the report's Filter in its Open event, e.g.:
Dim strWhere As String
strWhere = "[City] = ""New York"""
'Debug.Print strWhere
Me.Filter = strWhere
Me.FilterOn =True

For (b), your filter string needs to include a field name and a value to
match. It needs to look like the WHERE clause in a query. To see how it
should look, mock up a query, switch to SQL view, and look at the WHERE
clause.
 
Back
Top