Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

code crashes on one machine, but not another

Status
Not open for further replies.

Jackie

MIS
Feb 9, 2000
148
US
I execute the same code on two different machines. On one machine it works without error. (Both machines are running Windows 95 and Access 97). On the second machine I get the following message:

The Detail Window associated with this error states, "MSACCESS caused an invalid page default".

The corresponding code is below.

After I step through the code using the debug, the code cycles through, produces a separate report for each POC and does not crash.

Private Sub Report_Page()

'Identify a variable to hold the report file name
Dim strReportName As String
Dim strDir As String
Dim strPOCName As String
Dim strDateMonth As String
Dim strDateDay As String
Dim strDateYear As String
Dim strDate As String

'Get the path for which to store the report
'Remember that the default directory must be set in Access via Options Menu

strDir = CurDir & "\POC_Proj_Num\"


'Create date for file name

strDateMonth = Format(Date, "mmm")
strDateDay = Format(Date, "d")
strDateYear = Format(Date, "yyyy")
strDate = strDateMonth & strDateDay & strDateYear

'Get POC name

strPOCName = Me!txt_POC

'Establish the report file name
strReportName = strDir & strPOCName & strDate & "." & "rtf"

'Save the report to a file
DoCmd.OutputTo acReport, "POC_Project_Num", "RichTextFormat(*.rtf)", strReportName


'Close the report to contine processing the remaining POC's reports
DoCmd.Close acReport, "POC_Project_Num"

End Sub




The first time the code is executed the code crashes on the
DoCmd.Close acReport, "POC_Project_Num" line.
 
I was getting a similar error in Access 2000 when a user did not have the same Microsoft service pack as everyone else. I'm not sure that this is the cause of your problem but it might be worth a try. You could also make sure that both PCs have the same resource libraries installed and enabled.
 
Thank you. I will start with verifying the resource library and procede from there.
What is puzzleing is that the code worked on both machines. I am not sure what changed on the machine in which the error is occuring.

 
Take out the Docmd.close

You don't need it. The report isn't open when you use OutputTo.
 
When I remove the DoCmd.close the report is not run for the remaining POCs.

The application is set up as a client/server configuration. The data (backend) is stored on a network server.

The report is executed by the followiong code:

Private Sub cmd_PM_Due_date_Click()
Dim dbMLV As Database

Dim rstFindProj As Recordset

Dim strFindPM As String


Set dbMLV = CurrentDb
Set rstFindProj = dbMLV.OpenRecordset("qry_find_program_mgr")

'Run if records in the file
If rstFindProj.RecordCount > 0 Then

Do While Not rstFindProj.EOF

'Identify the program manager for which to run the report
strFindPM = rstFindProj.Fields("PM")
'Run the report for the specific PM
'Report is also sent to a file
'DoCmd.OpenReport "POC_Due_Date", acPreview, "", "[qry_POC_Due_Date].[POC_Name] = """ & strFindPM & """"
DoCmd.OpenReport "PM_Due_Date", acPreview, "", "[qry_PM_Due_Date].[PM] = """ & strFindPM & """"
'Advance to the next Point of Contact for which to run the report
rstFindProj.MoveNext
Loop

'Tell the user the reports are finished
MsgBox "Point of Contact by Fabrication Completion Date Reports Completed."

End If
End

End Sub





 
I have had a similar problem, which I found was caused by the page setup options. The original machine was setup for A3 and the second machine A4, once I had changed this it worked correctly.

Hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top