View Full Version : Printing Reports


Frankythekid
12-29-2004, 10:39 AM
I'm trying to print a specific report, not the whole list. I'm using the preview function first but it will show all records.
Currently I'm using this code:

Private Sub Command89_Click()
DoCmd.OpenReport "PO Log", acViewPreview, "[PO Number]=Forms!PO Log![PO Number]"
End Sub

But it shows all of the records, I just need the one with the PO Number i'm currently working on, only that one. So I can choose print and only print that record.
I guess this is a silly question, but i don't know why it will not work.

I appreciate the help...

WayneRyan
12-29-2004, 10:46 AM
Franky,

You need to isolate the Forms... reference so that Access can substitute
the real value of [PO Number]. And I think you missed a comma.


Private Sub Command89_Click()
DoCmd.OpenReport "PO Log", acViewPreview,,"[PO Number] = " & Forms![PO Log]![PO Number]"
End Sub


Wayne

Frankythekid
12-29-2004, 10:58 AM
thanks for the help again Wayne.

I wrote the same thing:

Private Sub Command89_Click()
DoCmd.OpenReport "PO Log", acViewPreview,,"[PO Number] = " & Forms![PO Log]![PO Number]"
End Sub

But the Do.Cmd line is in RED and it won't work, I guess is something in the syntax, but I don't know too much of programing in VBA.

Can you also recomend me a good book so I can learn how to program access 2000 using VBA. I just think that the only way to make my database better is by using this type of programming.

thanks again

WayneRyan
12-29-2004, 11:08 AM
Franky,

Remove the quote at the END of the line.

Wayne

Frankythekid
12-29-2004, 11:13 AM
Thanks Wayne, It works now. :)