Printing Records

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to print only one record instead of the whole 409,
i have a form created with a command button that links to
print a report, but i only want to print the newest record.

How do i do that.
 
There really isn't anything in a record that suggests it is the "Newest".
You would need to be able to have a method of determining the most recent
record by reading one or more stored values in the record. This might be the
value of an Autonumber.
I would create a combo box on the form that displays descriptive info from
the table. You can then modify your report opening code like:
Dim strWhere as String
strWhere = "EmployeeID=" & Me.cboEmployeeID
DoCmd.OpenReport "rptEmployee", acViewPreview, , strWhere
 
-----Original Message-----
I need to print only one record instead of the whole 409,
i have a form created with a command button that links to
print a report, but i only want to print the newest record.

How do i do that.
.
You can use a command button to print the current record
in a report. The following should work as long as your
primary key is a number data type.

Dim stDocName As String
Dim strWhere As String
strDocName = "Report Name"
strWhere = "[Field Name]=" & [Field Name]
DoCmd.OpenReport strDocName, acViewNormal, , strWhere
 
I think if you produce your report from a Query, it may
work. Construct a query asking for the one record, then
run your report.
 
I think if you produce your report from a Query, it may
work. Construct a query asking for the one record, then
run your report.

You can construct your report using a query for RecordSource that selects
all the records, and use the WhereCondition argument of DoCmd.OpenReport,
too. Especially in multiuser or client-server environments, I prefer to
creadt a new Query, as you mention, and replace the query that is the
RecordSource for the report -- it appears more efficient.

Larry Linson
Microsoft Access MVP
 
Back
Top