View Single Post
Old February 13th, 2006, 05:09 PM
kindler kindler is offline
Friend of Wrox
Join Date: Dec 2005
Location: , , .
Posts: 142
Thanks: 0
Thanked 0 Times in 0 Posts

My suggestion: Cheat.

Forms suck for printing, so what you do is create a report with all the same info as the form, then set the report's record source equal to a query that would bring up only the value currently on form2. Make sure you also set the record source for the report equal to (in this example) qryReport.

varIndex = Forms![Form2]![Index]
strReportQry = "SELECT * " & _
"FROM qryForm2Query " & _
"WHERE [qryForm2Query].[Index] = '" & varIndex & "' ;"

Set dbs = CurrentDb


For Each qdf In dbs.QueryDefs
    If qdf.Name = "qryReport" Then
        dbs.QueryDefs.Delete qdf.Name
    End If
Next qdf

Set qdfPassThrough = dbs.CreateQueryDef("qryReport")
qdfPassThrough.SQL = strReportQry
qdfPassThrough.ReturnsRecords = True

Set dbs = Nothing

DoCmd.OpenReport "rptReportName", acViewNormal