Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Filter then Parameter Window on Print Report on Lookup Field

Status
Not open for further replies.

newtech2

Technical User
May 22, 2002
18
0
0
US
I am quite new to Access programming. . .please forgive some of my names, etc. I have tried many different things to get my filtered form to print on my report, but no go. Here is the background.

I have a form, Main Job Form, with a print button that prints out the records on a report rptMiscPrintout. When a filter is done on Main Job Form, it should print out the filtered records using that same report. The code I have for the click event of the button is:

Private Sub Print_Click()
Dim stDocName As String
Dim strFilter As String
strFilter = Me.Filter
stDocName = "rptMiscPrintout"

If FilterOn = True Then
DoCmd.OpenReport stDocName, acViewPreview, , strFilter
Else
DoCmd.OpenReport stDocName, acViewPreview
End If

End Sub

When I filter on a look up field of Main Job Form, [Discipline ID] for example (which is actually Discipline Name), I receive the following parameter window when I click the print button: “Lookup_Discipline ID.Discipline Name” When I filter on any other field that is not a lookup, it works perfectly.

On the open event of rptMiscPrintout I have the following:

Private Sub Report_Open(Cancel As Integer)

'The recordsource much match the form in order for the print buttons on the form to work.pc

Me.RecordSource = Forms![Main Job Form].RecordSource

'Checks to see what the record source is and adds the appropriate title to report.pc
Select Case Forms![Main Job Form].RecordSource

Case "qryAllJobs"
lblTitle.Caption = "All Jobs"

Case "qryYTDJobsOpen"
lblTitle.Caption = "YTD Jobs Open"

Case "Job Query"
lblTitle.Caption = "All Jobs Excluding FL"

End Select

On [rptMiscPrintout] the field txtDisciplineName has the control source of: =DLookUp("[Discipline Name]","Discipline","[Discipline ID]= " & [Discipline ID])

If I could be guided to the next step to try, that would be just wonderful! Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top