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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

opening report limited by a field

Status
Not open for further replies.

ejmiller2

Programmer
Jun 3, 2003
38
US
i am trying to open a report that is limited by the SSN field of the table PeopleNotEmailed. When typing in the following i get a pop up box that asks me for [PeopleNotEmailed].[SSN]. I know i spelled it right and that there are numbers in there. If i instead plug in a number for [PeopleNotEmailed].[SSN] it works. any suggustions?...

DoCmd.OpenReport "Payroll", acPreview, , WhereCondition:="[PeopleNotEmailed].[SSN] = [SSN]"
thanks
eric
 
DoCmd.OpenReport "Payroll", acViewPreview, , "[SSN] = '" & Me.SSN & "'"

HTH


"I know what you're t'inkin', ma petite. Dat Gambit... still de suave one, no?"
 
one method is to create a query for the report and have the criteria based on the Form's value
Example Control on the Form (frmPayRoll) that will have the value is txtReportFilter, the query would be

Select * From TableName Where SSN = Forms!frmPayRoll.txtReportFilter Or Forms!frmPayRoll.txtReportFilter Is Null


The "Or Forms!frmPayRoll.txtReportFilter Is Null" part allows the report to be used to print all records or only the one selected by the TextBox. Just have to keep the Form Open to use the Filter condition.

PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top