Hi,
I'm using access2000 to create a dynamic report based on inputs from a form. Both the query and report do not reference the form in any way. I want to be able to select only certain rows from the query, so I thought I would use the WhereCondition field in DoCmd.OpenReport, but this seems to have no effect on the output whatsoever.
stDocName = "Report1"
cwh = SeenWhere.Value
If cwh = 1 Then
whereStr = " initial_contact_where <> 'Campus'"
ElseIf cwh = 2 Then
whereStr = " initial_contact_where = 'Campus'"
ElseIf cwh = 3 Then
whereStr = " 0 = 1"
End If
DoCmd.OpenReport stDocName, acPreview, stDocName, whereStr
initial_contact_where is a field in the query. I put the " 0 = 1" in there to test if the where condition was working at all, but even with this it returns all rows from the report.
I have tried setting RecordSource for the report to be the query name, and the actual SQL for the query but both return the exact same result.
I assume (from reading the help) that the WhereCondition just basically adds "WHERE " & whereStr to the end of the SQL query for the reports RecordSource, but it doesn't seem to do a thing. Is this correct? Am I doing something wrong?
damo317
I'm using access2000 to create a dynamic report based on inputs from a form. Both the query and report do not reference the form in any way. I want to be able to select only certain rows from the query, so I thought I would use the WhereCondition field in DoCmd.OpenReport, but this seems to have no effect on the output whatsoever.
stDocName = "Report1"
cwh = SeenWhere.Value
If cwh = 1 Then
whereStr = " initial_contact_where <> 'Campus'"
ElseIf cwh = 2 Then
whereStr = " initial_contact_where = 'Campus'"
ElseIf cwh = 3 Then
whereStr = " 0 = 1"
End If
DoCmd.OpenReport stDocName, acPreview, stDocName, whereStr
initial_contact_where is a field in the query. I put the " 0 = 1" in there to test if the where condition was working at all, but even with this it returns all rows from the report.
I have tried setting RecordSource for the report to be the query name, and the actual SQL for the query but both return the exact same result.
I assume (from reading the help) that the WhereCondition just basically adds "WHERE " & whereStr to the end of the SQL query for the reports RecordSource, but it doesn't seem to do a thing. Is this correct? Am I doing something wrong?
damo317