ToniMaura said:
I prefer change the report recordsource, how I do it with
code 'on the fly', opening the report in design mode and
then change the recordsource, saving changes and then
print?
That would then make different versions of the library mdb,
which kind of defeats the purpose of having a library. The
general way is to use code in each report's Open event to
Incorporate the IN phrase into the record source query's
From clause. In simple cases it might be something along
these lines:
Sub Report_Open()
Dim strSQL As String
Dim intPos As Integer
intPos = InStr(Me.RecordSource, " FROM ")
If intPos = 0 Then MsgBox("No From clause") : Exit Sub
IntPos = InStr(intPos + 6, Me.RecordSource, " ")
If intPos = 0 Then intPos = Len(Me.RecordSource)
strSQL = Left(Me.RecordSource, intPos) _
& "IN """ & pathtobackend & """ " _
& Mid(Me.RecordSource, intPos + 1)
Me.RecordSource = strSQL
. . .
End Sub
But that's just for the simple case of the report already
having an SQL statement in its record source. It gets even
trickier if the query can contain any JOIN clauses or other
complex stuff. It also leaves the open question of how the
report determines pathtobackend, but you'd have to have some
such mechanism regardless of which approach you take.
I really think you'd be better off having the library mdb
link to the tables in the backend mdb using a relinking
procedure from the web such as
http://www.mvps.org/access/tables/tbl0009.htm
At least this allows you to keep the reports independent of
the library management apparatus.
As you can see, placing forms/reports in a library mdb is
not a simple arrangement to set up and regardless of how you
approach it, it takes a lot of thought to work out all the
details.
--
Marsh
MVP [MS Access]