Can't get this code to work properly to print

F

forest8

Hi there

One of my reports consists of two separate reports. This is my VBA Cidse to
print the report out but as I mentioned in the subject, Access 2007 keeps
crashing. That is, when I try to print this report, Access 2007 closes and I
get an error message to send the issue to Microsoft. It reopens the database
and creates a backup.

How do I fix my issue? Here is the code:

Private Sub Print_Click()

Dim strDocName As String
Dim strWhere As String
strDocName = "R2-2a GPS_Youth"
strWhere = "Youth_ID=" & Me.Youth_ID
DoCmd.OpenReport "R2-2a GPS_Youth", acPrint, , strWhere
strDocName = "R2-2b GPS_Youth"

End Sub


R2-2a GPS_Youth" the correct name for the first report. There is a field in
the report named Youth_ID. There is a also a field in the subform named
Youth_ID.

The print button is on the subform.

I can't even print out the first part of my report yet alone both parts.

The two parts of my report is one single table with over 50 variables. I
know I should have normalized my table but to do that as this junction would
take more time than I can afford.

Please any advice is greatly appreciated.

PS. I earlier posted this question in the wrong section.
 
T

Tom van Stiphout

On Thu, 15 Apr 2010 20:15:01 -0700, forest8

You may have some form of corruption. This code looks good.
Make a safety copy of your db. Then compact it.
Here is an article about recovering from corruption:
http://allenbrowne.com/ser-47.html

-Tom.
Microsoft Access MVP
 

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