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'

Status
Not open for further replies.

Rasheed Shaik

Programmer
Mar 20, 2011
23
SA
Hi all
I have developed a application on VB6 with Access 2003 and Datareport. while running reports i am getting error of Run time Error'9'. The system is connected in network and using network printer on that, Any suggestions to resolve this error'
 

It would be nice to see some code that is creating the problem...

Have fun.

---- Andy
 
Private rs As New ADODB.recordset
Dim obj As PageSet.PrinterControl
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
Set obj = New PrinterControl
obj.ChngOrientationLandscape

rs.Open "select * from cheques where mata = '" & pro.Text & "'", con, 1, 3

If rs.RecordCount = 0 Then
MsgBox "No record found on query.", vbCritical, "Mackusoft"

Else
Set FullReport.DataSource = rs
Unload Me
FullReport.Show
End If

Set rs = Nothing

End Sub

 

Which line of code do you get the error on?
And what's the error's description?

Have fun.

---- Andy
 

Error 9 - Subscript out of range - indicates that you have an array somewhere and you are referencing an element of that array that does not exist.

You may have an array of 6 elements from 0 to 5, and you say: give me element number 6.

Or, you have an array with elements of 0, 1, 2, 3, 5, 6, 7, and you say – Give me number 4

Also, unrelated to your problem (I think) is this:
Code:
Else
    Set FullReport.DataSource = rs
    [red]Unload Me[/red]
    FullReport.Show
End If

Set rs = Nothing

End Sub
Line [tt]Unload Me[/tt] will unload your Form, but it will be re-loaded just to execute lines: [tt]FullReport.Show[/tt] and [tt]Set rs = Nothing[/tt] and you may see that your Form that you wanted to unload is loaded again.


Have fun.

---- Andy
 
Thnx i will verify and one more suggestion required , one report is running, but i don't show me records in run time, gives display only blank report.
Code for that is
Private rs As New ADODB.connection
Private rr As New ADODB.recordset
Private Sub cmdAcchu_Click()
Set rs = CreateObject("Adodb.connection")
rs.Provider = "Microsoft.jet.oledb.4.0"
'cs.Open App.Path & "\Medrar.mdb"
rs.Open "\\mika\medrar\Medrar.mdb"
Set rr = New ADODB.recordset

rr.Open "select * from Reser where Reno = '" & Combo1.Text & "'", rs, 1, 3

If rr.RecordCount = 0 Then
MsgBox "No record found on query.", vbCritical, "Medrar"

Else
Set Reservation.DataSource = rr
Unload Me
Reservation.Show vbModal
End If

Set rr = Nothing

End Sub
 
Have you tried to bring the file locally to see if that works instead of accessing it from the network?

If at first you don't succeed, then sky diving wasn't meant for you!
 
You indicated access 2003. Are you referencing this report on a system that has office 2007 or later installed?

In addition, are you certain that you are making a valid connection? You have not added an error handler in cmdAcchu_Click.

If at first you don't succeed, then sky diving wasn't meant for you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top