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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run-time error '9' subscript out of range

Status
Not open for further replies.

yobensh

Technical User
Jan 13, 2006
17
0
0
IL
Hi Experts!

I've made a small application using Access 2000 db, packed it and installed it on my personal pc. For me it works just fine. The problem begins right after the installation on users pc. When they click on any button it's giving them this error: "Run-time error '9' subscript out of range".
Can anyone tell me what could be wrong here, it's the first time I see this kind of error.

Thanks for your help
 
My crystal ball isn't working this week. You'll have to give us more information, or investigate the problem yourself more thoroughly first.

Obviously, you have a subscript somewhere that contains an invalid value. Is there some initial value that you are loading from the registry that is not yet set on the user's pc? Is there some initial condition that you expect, and that is present on your pc, but not on the user's?

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Hi Tracy

Thanks for your reply eventhough you don't own a crystal ball...;-)
Here is what I got so far - after a deep investigation, it seems that the reason for that error to occour is the "pageset" thing.
What I'm trying to do here is to print a report at Landscape Orientation. On users pc, I've copied the file pageset.dll and registered it.

Still, the user gets this error....
Here is the code, hope you could tell me what is wrong with it!


Code:
Option Explicit

Private Sub btnPrintReport_Click()

Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim obj As PageSet.PrinterControl
Dim strTitle As String

On Error GoTo errorhandler

Set obj = New PrinterControl
obj.ReSetOrientation
obj.ChngOrientationLandscape

cn.Open "DSN=Process"
rs.Open "Data", cn, adOpenKeyset, adLockOptimistic

strTitle = "Print Report"

Set DataReport1.DataSource = Adodc1.Recordset

DataReport1.TopMargin = 500
DataReport1.LeftMargin = 1000
DataReport1.Height = 8280
DataReport1.Width = 12000
DataReport1.Top = 0
DataReport1.BottomMargin = 500

DataReport1.Sections("rptHeader").Controls("lblTitle").Caption = strTitle

DataReport1.Caption = "Process Printout"

DataReport1.Show

rs.Close
cn.Close

Exit Sub

errorhandler:
MsgBox "Can't print report!", vbCritical, "Error"

obj.ReSetOrientation

rs.Close
cn.Close

End Sub

Thanks!!!


 
To be honest, It does not appear as if the error would be coming from this subprocedure. The error is probably 'floating up ' from another subprocedure and catching here. Usually, when I see an error 9, I look in the functions or subs where I am using some sort of array.
 
I would generally agree with BrianLW, but in this case I don't see you making any calls to other procedures.

As a test to help isolate the problem, you could comment out all the code having to do with the the PageSet object. You might get a report printing out in the wrong orientation, but at least it would tell you if that's the cause of your problem.

Is the code in your other buttons similar (i.e. printing reports)?
 
The 'error 9' could be raised from this line:
Code:
DataReport1.Sections("rptHeader").Controls("lblTitle").Caption = strTitle
if either of the quoted names is misspelt. I usually use the ordinal number for the sections collection as I've had a few random 'error 9' problems with it

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Hi,

Figured out what caused that error - end user is using a remote printer thus when trying to open the report system is expecting to find a physical printer...
Therefore, simple solution is to connect the printer directly to the pc and not by net connection.

Thanks for all who tried helping me here!!
Yoav.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top