Printing without a Query, and without a Printer Dialog

Hi there,

I am creating a really basic application which connects with our Warehouse System. The idea behind is that it generates a barcode, which will then be printed. Everything is working fairly well, and was pretty easy to make. (Thanks to MBS products!)

However, the easy task of printing makes the application a bit more complicated because, to my surprise. Printing is not easy at all. It’s almost impossible, and with very unclear explanations on how to tackle many issues.

It’s only with how reports work. Maybe I just don’t understand its idea, or how I should tackle this. That’s why I thought, perhaps I could ask the community about some suggestions. Since we really need this software, we are also open for a paid consultation, if there are any suggestions for that.

  1. At first, I thought, I already have the data. No need to fetch it again to print it. However, as it seems right now, you actually need a real data set to even print. So, fine, I query the Database again, (Since Creating a Special DataSet with the documentation example didn’t really seem to work. Maybe the documentation is a bit older?)
  2. I don’t want any printer dialog. I have preselected the printer already, and want to print it.

So, how can I do this. I have three strings, and I also need to add a barcode, generated with BarcodeMBS to a report, or at least the printed page. I thought of something like this, but this does not seem to work without Report.Run, and even with Report.Run, it still throws an NilObjectException, without any clear clarification.

Dim QueryResult As RecordSet = PreparedStatement.SQLSelect(App.SearchedString)

If QueryResult <> Nil Then
  While Not QueryResult.EOF
    Dim ArticleName As String = QueryResult.Field("Description").StringValue
    Dim Brand As String = QueryResult.Field("Class_01").StringValue
    Dim Package As String = QueryResult.Field("Class_04").StringValue
    
    G = OpenPrinterDialog(Ps, Nil)
    
    If G <> Nil Then
      SimpleLabelReport.Document.Print(G)
    End If

.....

Best regards,
Pascal

Don’t use Report for this. Since you already have a PrinterSetupString, Ps, call OpenPrinter instead of OpenPrinterDialog. Then you get a Graphics object, G, which you can draw into directly. No need for the Report class for this.