![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 | |
|
Programming Guru
![]() ![]() |
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:
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 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 .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 SubAnyways, 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! |
|
|
|
|
|
|
#2 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
What's the error? Maybe there's a new version of gPrinter that does it a little differently.
|
|
|
|
|
|
#3 | ||
|
Programming Guru
![]() ![]() |
Quote:
Quote:
I've tryed all different version of qPrinter and still get the same error. I am currently installing VS6 on a different box in the hopes that it's my computer and not the code. Things are pointing to a problem with windows on my computer. Not the code. I'll let you guys know if installing on a different computer fixes it. Thanks
__________________
Profanity is the one language that all programmers understand. Check out my Blog <---updated Nov 30 2007! |
||
|
|
|
|
|
#4 |
|
Newbie
Join Date: Oct 2004
Posts: 1
Rep Power: 0
![]() |
Hi Nick,
I'm not sure what might be causing the problem but it sounds like the qPrint object is failing to be created. When the code reaches the With block, qPrint is Nothing. There are a couple of common causes:
If their is an error, let me know either here or by mail and I'll see if I can find a solution. Regards Edward [qbd software ltd] |
|
|
|
|
|
#5 |
|
Programming Guru
![]() ![]() |
No worries everybody. I tryed compiling it on a diffeent computer and it worked just fine. It was somthing to do with my version of windows and the way it was affecting my compiler. The funny part about it is that the other computer had no updates to the VS suite, but mine did. Looks to me like m$ might have screwed me over once again ;-)
Thanks for all your replys.
__________________
Profanity is the one language that all programmers understand. Check out my Blog <---updated Nov 30 2007! |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|