hi.
i'm trying to order a report based on a condition selected in a form that calls the report.
for instance
'builds whereCondition
varWhere = (varWhere + " AND ") & _
"[field1] IN (Select field1 From tbl1, tb2 " & _
" WHERE tbl1.field3 = tbl2.field4)"
'this is list that has several field based on which the report will be ordered once opened. (But it doesn't work, i get a syntax error)
If Me!Order_List = "Last Name" Then
varWhere = (varWhere + " ORDER BY fld5")
End If
DoCmd.OpenReport "rptContacts", acViewPreview, , Wherecondition:=varWhere
I sure that the building of the first varWhere is good cuz it works once i take out the second one. (ORDER BY)
Is what i'm doing possible? please give me some advice.
i'm trying to order a report based on a condition selected in a form that calls the report.
for instance
'builds whereCondition
varWhere = (varWhere + " AND ") & _
"[field1] IN (Select field1 From tbl1, tb2 " & _
" WHERE tbl1.field3 = tbl2.field4)"
'this is list that has several field based on which the report will be ordered once opened. (But it doesn't work, i get a syntax error)
If Me!Order_List = "Last Name" Then
varWhere = (varWhere + " ORDER BY fld5")
End If
DoCmd.OpenReport "rptContacts", acViewPreview, , Wherecondition:=varWhere
I sure that the building of the first varWhere is good cuz it works once i take out the second one. (ORDER BY)
Is what i'm doing possible? please give me some advice.
Last edited: