dick penny said:
Wayne,
Here goes, but I have posted in several groups for 2-3 weeks. All I
get is suggestions to use Replace(....) to modify the strings. Yes, I
think this can be done. But WHY is everyone so resistant to passing
a recordset to a report? If it cannot be done (a limit of A2K)
sobeit, just tell me.
I don't see anything in the help file that says so, but the error
message I get when I try to set the Recordset property of a report --
"Run-time error '2593': This feature is not available in an MDB." --
seems to state pretty clearly that you can't do this in an MDB file,
though it implies that you may be able to do it in an ADP. Further
research turns up this KB article:
http://support.microsoft.com/default.aspx?scid=kb;en-us;287437&Product=acc2002
So your answer is clear: you can't do it the way you want; at least
not if you're working in an MDB. Since you keep talking about ADO
recordsets, are you working in an ADP? Otherwise, the form's recordset
would normally be a DAO recordset.
[snip]
fails, 2 examples
===========
?me.Filter
((Lookup_cboPos1.Positions="A/P Manager"))
?me.Filter
((Lookup_cboPos1.Positions="A/P Manager")) OR
((Lookup_cboPos3.Positions="Accountant Sr"))
I can see what's going on; those "Lookup_..." names are a dead
giveaway. Your form is being filtered on the displayed column of a
combo box, when that column is not the bound column. Therefore, the
values being filtered on don't exist in the form's recordsource at all.
What Access does in these cases is create an internal lookup query and
join it to the form's recordsource, so as to provide the values for
filtering. This internal query is given the prefix "Lookup_", which is
tacked onto the name of the control being filtered.
Hmm, what to do about it. I can think of two possible solutions, both
complicated. The first is to create a recordsource query for your
report that defines the same helper lookup queries as the includes the
same. That way, the form's filter string will be just as applicable to
the report because the report's recordsource will also contain fields
such as Lookup_cboPos1.Positions and Lookup_cboPos3.Positions. I've
just tested this out with a test form and report and it works in
principle.
The second approach involves you preprocessing the filter string in code
to identify the lookup fields; then do your own lookup and replace
those criteria in the filter string with the field names and values that
*will* appear in the report's recordsource. For example, you would
start with this string:
((Lookup_cboPos1.Positions="A/P Manager"))
parse out the Lookup_cboPos1.Positions specification, identify the table
and field being looked up, figure out that (maybe) this lookup
corresponds to the Pos1 field being equal to 123, rewrite the filter
string to:
((Pos1=123))
and pass that to the report. All this parsing and interpreting could be
difficult, but I think it could be made to work.