Ok… the below code is in a right click menu in my listbox. What it is supposed to do is pass the record (jobnumber) of a listbox item, then query up that jobnumber and pass it to the report. There are 26 fields in that record that I do some simple math on to come up with flow rates and a % increase/decrease between two different tests.
My question is…for example…
flow_050 is a field in the db
flow2_050 is a field in the db
These two represent a “before and after” picture of a flow rate.
I want to do some percentage difference between the two and I can do that in the beforerprinting event, the problem is if I do that, do I have to create a global variable called gFlow_050, assign orders.flow_050’s value to it, then do the math? That seems like alot of work. I’d have to create 26 additional global variables for this. Doesnt “orders” get passed to the report so I can get the value from orders.flow_050 etc etc?
Another question…(not important now…the above question is of a higher priority)
If you’re thinking, why am I opening the db here and not as soon as I run the app… well I am. But for some reason, if I do not open it AGAIN, I get a NILobject error on “orders”.
[code] gLoadRecord = Me.Cell(Me.ListIndex, 0)
Dim dbFile As New FolderItem("/home/themagicm/.portflowanalyzer/portflowdb.sqlite")
mDb = New SQLiteDatabase
mDb.DatabaseFile = dbFile
If mDb.Connect Then
mIsConnected = True
Else
mIsConnected = False
msgbox("Error opening SQLite database: " + mDb.ErrorMessage)
quit
End If
// Build the SQL statement that will be used to select the records
Dim sql As String
sql = "SELECT * FROM flow_head where jobnumber=" + gLoadRecord
Dim rpt As New HeadFlowReport
// Now we select the records from the database and add them to the list.
Dim orders As RecordSet
orders = mDB.SQLSelect(sql)
If orders = Nil Then
MsgBox("No records found to print.")
Else
Dim ps As New PrinterSetup
'gFlow_050 = val(orders.field("flow_050").stringvalue)
// set the resolution to 300 DPI for printing
ps.MaxHorizontalResolution = 300
ps.MaxVerticalResolution = 300
If ps.PageSetupDialog Then
Dim g As Graphics
g = OpenPrinterDialog(ps, Nil)
If g <> Nil Then
// if the report runs successfully
If rpt.Run(orders, ps) Then
rpt.Document.Print(g)
End If
End If
End If
End If[/code]