Printing only 1 record from a Query

  • Thread starter Newf via AccessMonster.com
  • Start date
N

Newf via AccessMonster.com

Hi!
I've been trying to print only 1 record - current record - but when printing
all records are printed. This is the code I have:

Dim strWhere As String
If Me.Dirty Then 'Save any changes.
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "SELECT A RECORD TO PRINT"
Else
strWhere = "[tblPersonal.Id_Personal] = " & Me.[tblPersonal.Id_Personal]
DoCmd.OpenReport "rptTEST", acViewPreview, strWhere
End If

I also have found this code but it seems not to work. Even when I take that
code out and place this one in it doesn't work:

Dim strDocName As String
Dim strWhere As String
strDocName = "rptTEST"
strWhere = "[Id_Personal]=" & Me!Id_Personal
DoCmd.OpenReport strDocName, acPreview, , strWhere


Can some kind person be able to help me out???

Thanks in advance!

Newf
~Everyone needs a Newfie as a friend~
 
B

Bill

In your DoCmd statement, you are missing a comma
that the strWhere be treated as the "condition". I.e.,
DoCmd.OpenReport "rptTEST", acViewPreview,, strWhere
The 3rd parameter to OpenReport is the filter name.
Bill
 

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