So close to printing my subform to a report but

espealman

New member
Local time
Today, 03:32
Joined
Sep 12, 2006
Messages
5
I have a subform that displays results based on selections from cascading boxes on the form. I am trying to print them to a report. I think my procedure is correct for the print button and Im afraid my problem is that the form is not based on a seperate query. Is that they only way to be able to print? It is based on procedures defined in the cascading boxes. How can correct it so it will print the results to a report? Thanx.
 

Attachments

eg

Private Sub cboBox_AfterUpdate()
Me.SUB_FORM.Form.RecordSource = "SELECT * FROM QUERY_NAME " & CreateFilter
Me.SUB_FORM.Requery
End Sub

Private Sub btnReport_Click()
Dim strDocName As String
Dim strCriteria As String
strDocName = "REPORT_NAME"
strCriteria = CreateFilter

DoCmd.OpenReport strDocName, acPreview, WhereCondition:=strCriteria
End Sub

Public Function CreateFilter() As Variant
Dim varWhere As Variant

varWhere = Null ' Main filter

If Me.cboBox <> "" Then
varWhere = varWhere & "([FIELD_NAME_ON_TABLE] =""" & Me.cboBox & """)"
End If

varWhere = "WHERE " & varWhere
CreateFilter = varWhere 'EDIT! I forgot to add it! :p
End Function

'note: query_name should be report_name's source object

There is a small-scale example I wrote. Hopefully it will help you with the layout of your idea!
 
Last edited:
Thanks a bunch for replying Ecron. :D I finally got it figured out so Im a happy camper.
 

Users who are viewing this thread

Back
Top Bottom