Creating/Printing a report using selected data in a Table

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

Guest

I'm trying to do this for my job and am getting very frustrated.
I created a table in Access that has a document number and than a column for
every department that a copy of that document should go to.

What i want to be able to do is select a row and create a report with ONLy
that information. Like for example:

The report should give me the Document Number and list the departments that
i selected for that Doc Number. Anyone help please asap?!!?
 
After you have built your tables, you should no longer be working in them.
You should work in forms.

In a form, you can add a button to do what you want. The following code
could be modified to do what you are asking for...


Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.

Me.Dirty = False

End If

If Me.NewRecord Then 'Check there is a record to print

MsgBox "Select a record to print"

Else

strWhere = "[ID] = " & Me.[ID]

DoCmd.OpenReport "MyReport", acViewPreview, , strWhere

End If

End Sub



Notes: If your primary key is a Text type field (not a Number type field),
you need extra quotes: strWhere = "[ID] = """ & Me.[ID] & """"

If you want the report to print without preview, replace acViewPreview with
acViewNormal.



See also: http://allenbrowne.com/casu-15.html
 
Back
Top