Printing one record of a table

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

Guest

Does anyone know if there is a way to just print one record out of a table in
a report format? Thanks in advance.
 
Yes, either filter your report or your query so it only pulls the desired
record. You'd need to give us more details about how you would determine
the "one record" you want in order for us to give you a specific answer.
 
This is probably more complicated than what you want to do, and someone may
come up with an easier solution.

But here's what I do. You write the report, so that it looks the way you
want it to.

Then you make a form, which asks the person which record they want to print.

Add a button to the form, which will open up your report in preview manner.

Add code to the button (There is code there already, click on the Build
event item that shows when you right click the button in design view).

Dim stWhere As String
stWhere = "[FVFUnNo] = '" & Me.FVFUnNo & "'"
DoCmd.OpenReport stDocName, acPreview, , stWhere

StWhere has to eventually be a string which surrounds a text field with
single quotations, a number field is left alone, and I believe that a date
field should be surrounded by number signs (#). The code as it stands is for
finding a record defined by FVFUnNo, which is a text field.

The DoCmd.OpenReport stDocName,acPreview line will already be there.
Add the ,,stWhere at the end of the line, and put the rest of the code given
above that line.

Hope this helps.
 
r. howell said:
This is probably more complicated than what you want to do, and someone may
come up with an easier solution.

But here's what I do. You write the report, so that it looks the way you
want it to.

Then you make a form, which asks the person which record they want to print.

Add a button to the form, which will open up your report in preview manner.

I use a similar method, but don't need to modify any code. Instead, I
make the data source for the report a query which is based on the value
selected (to identify the desired record) in the form. If you leave the
form open (but minimized) when you build the criterion in the query, you
can find the proper object (I make sure to give it a meaningful name) by
searching the open forms.

Sigurd Andersen
Add code to the button (There is code there already, click on the Build
event item that shows when you right click the button in design view).

Dim stWhere As String
stWhere = "[FVFUnNo] = '" & Me.FVFUnNo & "'"
DoCmd.OpenReport stDocName, acPreview, , stWhere

StWhere has to eventually be a string which surrounds a text field with
single quotations, a number field is left alone, and I believe that a date
field should be surrounded by number signs (#). The code as it stands is for
finding a record defined by FVFUnNo, which is a text field.

The DoCmd.OpenReport stDocName,acPreview line will already be there.
Add the ,,stWhere at the end of the line, and put the rest of the code given
above that line.

Hope this helps.

:

Does anyone know if there is a way to just print one record out of a table in
a report format? Thanks in advance.
 
Back
Top