Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Oct 28th, 2004, 12:33 PM   #1
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
Hey,

I just finished updating some of my old code for one of the programs that i wrote for my company. However i am having problems with a section of code that i didn't even touch. I changed the way that the program looks at the configureation file, but the problem that i am having is with the reporting section of the program. It's horribly confusing. The error that i am getting is:

Quote:

Run Time Error "91":
Object Varible or With Block varible not set.
The third party printer object that i am using is called qPrinter and has worked perfectly till i changed the configuration code that has nothing to do with this dll. I am developing this program for windows 98. It's almost like the object varible isn't being set but when i comment out the line were i set it blows up there. Other wise it blows up just after the with block starts. Anywyas, i guess i should post some code, to help explain my problem.

Private Sub mnuInventorySummary_Click()
'*****************************************************************************************************************
'** Purpose: This generates the inventory summary!                               **
'** Pre: There just has to be some inventory.                                  **
'** Post: Generates the summary and lets the user print it.                           **
'** Date Created: Mar 16-04                                           **
'** Date Finished: Mar 16-04                                          **
'*****************************************************************************************************************
'var declair:
'Printer Stuff:
Dim lItem As Long
Dim lSubItem As Long
Dim lSubTot As Integer
Dim sTemplate As String
Dim qFT As qcFormatBlock
Dim lValue As Long
Dim sText As String
Set qPrint = New qcPrinter
As you can see that i set the object varible here. It is declaired as a Private Var at the top of the module.
Dim sWidth As Single
'Inventory Stuff:
Dim Inv As InvenTools
Dim db As DBObj
Dim rs, rs2 As Recordset
Dim SubClasses() As String
Dim x, y As Integer
Dim Total As Currency
Dim num As Integer

Dim stuff() As String
stuff() = grab_config()

Me.MousePointer = vbHourglass
DoEvents
'first we need to check for inventory.
Set Inv = New InvenTools

With Inv
  .DSN = stuff(4)
    .data = stuff(0)
    .User = stuff(1)
    .Pass = stuff(2)
    .Port = stuff(3)
End With

If Inv.Connect = True Then
  'checking for inventory
  If Inv.CheckForInven = True Then
    'we can gen the report.
    With qPrint.Document
      .Reset
This is the line that the error comes up on (the .Rest line).
      .ScaleMode = eMillimetre
      .MarginLeft = 5
      .MarginRight = 5
      'Standard Header
      .SetHeaderContent Standard_hf, "Proform Casting:Inventory Summary:", "Arial Narrow", 22
      .SetHeader(Standard_hf) = True
      'Standard Footer
      .SetFooterContent Standard_hf, Date & "<FORCE><ALIGN=Right>Page #PageNumber# of #PageTotal#", "Arial Narrow", 12
      .SetFooter(Standard_hf) = True
      'Creating Format Blocks for templates.
      'Template: Item Title
      .AddTemplateBlock "Arail Narrow", 10, "tTitle", True, , , vbWhite, eLeft, 5, , 180, , True
      Set qFT = .Templates("tTitle")
      qFT.Top = 10
      qFT.ShowBorder = True
      qFT.BorderShading = vbBlack
      qFT.BorderStyle = fbsAll
      qFT.BorderMargin = 1
      'Template: Table Header
      .AddTemplateBlock "Times New Roman", 8, "tHeadC1", True, , , , , 5, , 70, True, True
      Set qFT = .Templates("tHeadC1")
      qFT.BorderShading = RGB(128, 128, 128)
      qFT.ShowBorder = True
      qFT.BorderLine = 1
      qFT.BorderColor = vbWhite
      .AddTemplateBlock "Times New Roman", 8, "tHeadC2", True, , , , , 75, , 30, True, True
      Set qFT = .Templates("tHeadC2")
       qFT.BorderShading = RGB(128, 128, 128)
      qFT.ShowBorder = True
      qFT.BorderLine = 1
      qFT.BorderColor = vbWhite
      .AddTemplateBlock "Times New Roman", 8, "tHeadC3", True, , , , , 105, , 30, True, True
      Set qFT = .Templates("tHeadC3")
      qFT.BorderShading = RGB(128, 128, 128)
      qFT.ShowBorder = True
      qFT.BorderLine = 1
      qFT.BorderColor = vbWhite
      .AddTemplateBlock "Times New Roman", 8, "tHeadC4", True, , , , , 135, , 35, True, True
      Set qFT = .Templates("tHeadC4")
       qFT.BorderShading = RGB(128, 128, 128)
      qFT.ShowBorder = True
      qFT.BorderLine = 1
      qFT.BorderColor = vbWhite
      .AddTemplateBlock "Times New Roman", 8, "tHeadC5", True, , , , , 170, , 30, False, True
      Set qFT = .Templates("tHeadC5")
       qFT.BorderShading = RGB(128, 128, 128)
      qFT.ShowBorder = True
      qFT.BorderLine = 1
      qFT.BorderColor = vbWhite
      ' Template: Table Item Odd
      .AddTemplateBlock "Times New Roman", 8, "tOddC1", , , , , eCentre, 5, , 70, True, True
      Set qFT = .Templates("tOddC1")
      qFT.BorderShading = RGB(240, 240, 240)
      qFT.ShowBorder = True
      qFT.BorderLine = 1
      qFT.BorderColor = vbBlack
      qFT.BorderMargin = 1
      qFT.BorderStyle = fbsTopLeft
      .AddTemplateBlock "Times New Roman", 8, "tOddC2", , , , , eCentre, 75, , 30, True, True
      Set qFT = .Templates("tOddC2")
      qFT.BorderShading = RGB(240, 240, 240)
      qFT.ShowBorder = True
      qFT.BorderLine = 1
      qFT.BorderColor = vbBlack
      qFT.BorderMargin = 1
      qFT.BorderStyle = fbsTopRight
      .AddTemplateBlock "Times New Roman", 8, "tOddC3", , , , , eCentre, 105, , 30, True, True
      Set qFT = .Templates("tOddC3")
      qFT.BorderShading = RGB(240, 240, 240)
      qFT.ShowBorder = True
      qFT.BorderLine = 1
      qFT.BorderColor = vbBlack
      qFT.BorderMargin = 1
      qFT.BorderStyle = fbsTopLeft
      .AddTemplateBlock "Times New Roman", 8, "tOddC4", , , , , eCentre, 135, , 35, True, True
      Set qFT = .Templates("tOddC4")
      qFT.BorderShading = RGB(240, 240, 240)
      qFT.ShowBorder = True
      qFT.BorderLine = 1
      qFT.BorderColor = vbBlack
      qFT.BorderMargin = 1
      qFT.BorderStyle = fbsTopRight
      .AddTemplateBlock "Times New Roman", 8, "tOddC5", , , , , eCentre, 170, , 30, False, True
      Set qFT = .Templates("tOddC5")
      qFT.BorderShading = RGB(240, 240, 240)
      qFT.ShowBorder = True
      qFT.BorderLine = 1
      qFT.BorderColor = vbBlack
      qFT.BorderMargin = 1
      qFT.BorderStyle = fbsTopRight
      ' Template: Table Item Even
      .AddTemplateBlock "Times New Roman", 8, "tEvenC1", , , , , eCentre, 5, , 70, True, True
      Set qFT = .Templates("tEvenC1")
      qFT.BorderShading = RGB(220, 220, 220)
      qFT.ShowBorder = True
      qFT.BorderLine = 1
      qFT.BorderColor = vbBlack
      qFT.BorderMargin = 1
      qFT.BorderStyle = fbsTopLeft
      .AddTemplateBlock "Times New Roman", 8, "tEvenC2", , , , , eCentre, 75, , 30, True, True
      Set qFT = .Templates("tEvenC2")
      qFT.BorderShading = RGB(220, 220, 220)
      qFT.ShowBorder = True
      qFT.BorderLine = 1
      qFT.BorderMargin = 1
      qFT.BorderColor = vbBlack
      qFT.BorderStyle = fbsTopRight
      .AddTemplateBlock "Times New Roman", 8, "tEvenC3", , , , , eCentre, 105, , 30, True, True
      Set qFT = .Templates("tEvenC3")
      qFT.BorderShading = RGB(220, 220, 220)
      qFT.ShowBorder = True
      qFT.BorderLine = 1
      qFT.BorderColor = vbBlack
      qFT.BorderMargin = 1
      qFT.BorderStyle = fbsTopLeft
      .AddTemplateBlock "Times New Roman", 8, "tEvenC4", , , , , eCentre, 135, , 35, True, True
      Set qFT = .Templates("tEvenC4")
      qFT.BorderShading = RGB(220, 220, 220)
      qFT.ShowBorder = True
      qFT.BorderLine = 1
      qFT.BorderMargin = 1
      qFT.BorderColor = vbBlack
      qFT.BorderStyle = fbsTopRight
      .AddTemplateBlock "Times New Roman", 8, "tEvenC5", , , , , eCentre, 170, , 30, False, True
      Set qFT = .Templates("tEvenC5")
      qFT.BorderShading = RGB(220, 220, 220)
      qFT.ShowBorder = True
      qFT.BorderLine = 1
      qFT.BorderMargin = 1
      qFT.BorderColor = vbBlack
      qFT.BorderStyle = fbsTopRight
      'Now for the total row template.
      .AddTemplateBlock "Times New Roman", 8, "tTotal", , , , vbWhite, eRight, 5, , 180, False, False
      Set qFT = .Templates("tTotal")
      qFT.ShowBorder = True
      qFT.BorderLine = 1
      qFT.BorderMargin = 1
      qFT.BorderColor = vbBlack
      qFT.BorderShading = fbsAll
      'OK now to fill the report with the items.
      
      'setting up db object
      Set db = New DBObj
      Set rs = New Recordset
      
      With db
        .DSN = stuff(4)
    .data = stuff(0)
    .User = stuff(1)
    .Pass = stuff(2)
    .Port = stuff(3)
      End With
      
      If db.Connect = True Then
        Set rs = db.dbSelect("itemclass", "class", "")
        If rs.BOF <> True Then
          x = 0
          rs.MoveFirst
          Do
            x = x + 1
            rs.MoveNext
          Loop Until rs.EOF = True
          ReDim Classes(x)
          rs.MoveFirst
          x = 0
          Do
            Classes(x) = rs!ItemClass
            x = x + 1
            rs.MoveNext
          Loop Until rs.EOF = True
          rs.MoveFirst
          x = 0
          Do
            Total = 0
            'Table Title.
            .AddTextBlock "Information About: " & rs!ItemClass, "tTitle", , , , "bITitle" & x & rs!ItemClass, "bIHeadE" & x, , True
            'Column Headers.
            .AddTextBlock "Name:", "tHeadC1", , , , "bIHead" & x
            .AddTextBlock "Num:", "tHeadC2", , , , "bIHeadA" & x
            .AddTextBlock "Cost ea:", "tHeadC3", , , , "bIHeadB" & x
            .AddTextBlock "Last Transaction:", "tHeadC4", , , , "bIHeadC" & x
            .AddTextBlock "Total:", "tHeadC5", , , , "bIHeadD" & x
            'ok now to go through the sub Item class and inser the inventory values into the report.
            Set rs2 = db.dbExecute("SELECT * FROM Inventory WHERE ItemClass='" & rs!ItemClass & "' ORDER BY ItemSubClass ASC;")
            If rs2.BOF <> True Then
              rs2.MoveFirst
              lValue = 1
              Do
                If lValue Mod 2 = 1 Then
                  sTemplate = "tOdd"
                Else
                  sTemplate = "tEven"
                End If
                'Colum Info
                .AddTextBlock rs2!itemsubclass, sTemplate & "C1"
                .AddTextBlock rs2!Amount, sTemplate & "C2"
                .AddTextBlock "$" & rs2!cost, sTemplate & "C3"
                .AddTextBlock rs2!lasttrans, sTemplate & "C4"
                .AddTextBlock "$" & (rs2!cost * rs2!Amount), sTemplate & "C5"
                Total = Total + (rs2!cost * rs2!Amount)
                rs2.MoveNext
              Loop Until rs2.EOF = True
              'Total at the bottom of the Colum Info
              .AddTextBlock "$" & Total, "tTotal", , , , "iTotal" & rs!ItemClass & Total
              
              .DocumentItems.RecentText.KeepWithNext = False
              .DocumentItems.RecentText.UseTemplateKeepNext = False
              .DocumentItems(.DocumentItems.count - 1).BorderStyle = fbsTop + fbsLeft + fbsBottom
              .DocumentItems.RecentText.BorderStyle = fbsTop + fbsBottom + fbsRight
              x = x + 1
              rs.MoveNext
            End If
          Loop Until x = (UBound(Classes))
        End If
      End If
    End With
    Me.MousePointer = vbDefault
    qPrint.PrinterChanged
    qPrint.Preview
  Else
    Me.MousePointer = vbDefault
    MsgBox "There is no inventory, therefore I can't generate a inventory summary!"
  End If
End If
Inv.Disconnect
Set Inv = Nothing
End Sub


Anyways, i know my code is sloppy but i don't have the time to re-write the code. Does anybody see a reason for getting the error that i am? I am conpleatly confused about this issue..since it was working and all of a sudden it isn't. I am starting to think that it might be just somthing screwy with my winblows box because the examples that come with the dll source get the same error as my code. I even tryed un installing the .NET frame work (v1.1) that microsoft wanted me to update too. Still doesn't work however. Anyways, thanks for the help in advance.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:59 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC