Print Current Record From A Form

K

Kenny G

Hello,

Using Access 2002

I am trying to print the current record from a form. I do get the report
using the below listed code. However, I don't just get the current
information on the subform, I get all the information on the subform and I
just want the data from the displayed record. Any help will be appreciated.

Private Sub cmdPrintCurrentRecord_Click()
Dim strWhere As String

strWhere = "[AutoID] = " & Me.[AutoId]
DoCmd.OpenReport "Client History Individual Report", acViewPreview, ,
strWhere
End Sub
 
K

Klatuu

The code looks correct, but based on your description, my guess is that
AutoID is actually a foreign key to the parent record on the main form. If
you want just a specific record on the sub form, you need to have that
record as the current record in the subform and use a field that is unique
to the child record. In fact, you probably need both fields to compare on.
 
K

Kenny G

Klatuu,

Thanks!
--
Kenny G


Klatuu said:
The code looks correct, but based on your description, my guess is that
AutoID is actually a foreign key to the parent record on the main form. If
you want just a specific record on the sub form, you need to have that
record as the current record in the subform and use a field that is unique
to the child record. In fact, you probably need both fields to compare on.

Kenny G said:
Hello,

Using Access 2002

I am trying to print the current record from a form. I do get the report
using the below listed code. However, I don't just get the current
information on the subform, I get all the information on the subform and I
just want the data from the displayed record. Any help will be
appreciated.

Private Sub cmdPrintCurrentRecord_Click()
Dim strWhere As String

strWhere = "[AutoID] = " & Me.[AutoId]
DoCmd.OpenReport "Client History Individual Report", acViewPreview, ,
strWhere
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top