• DataReport without DataSource (VB6)

    Author
    Topic
    #399398

    Not sure if I titled this thread correctly but it will make sense in a while.

    I’m new to VB and picking things up as I go, but here’s what I need to do.

    I’ve created a utility which will pick up PDF’s and JPG’s from designated folders and view them together on one screen.
    The pdf control allows printing, straight forward enough, but need to print the Images by selection and place them on a DataReport.

    I’ve checked out the DataReport and done several Googles for tutorials, but can’t find anything to get me started.
    So the question is, how do I transfer my selected images from the list (List is already created) and have them nicely spaced on a report.
    The DataReport looks very similar to Access but haven’t got a clue how to start.

    I don’t need to link to a database, hence the thread title.

    Can some-one help ?

    Viewing 1 reply thread
    Author
    Replies
    • #771538

      I’ve checked again this morning and every example I can find relates to the datareport having a recordset, table or other source from databases.
      Does this have to be so and can’t a report be based on a folders content or VB form list control using a path to the folder ?

      • #771720

        You can create a recordset in memory using ADO, Dave. That might be your best option in this case. Build an array of the data you want to display in the report, then loop through its elements and use the .AddNew method of the ADO recordset for each record and use the Array() function to build a paramarray of the individual fields for each record. It’s a little complicated to describe (and a bit to do) but it will convert an array of structured data into a recordset, which you can then use to populate a form or report.

        • #771728

          Charlotte
          The form I use to show images kind of represents a thumbnail view. (Basically picture controls, “Img1 thru to Img12”)

          Could I use a similar form to achieve my goal using the PrintForm method ?
          or
          Recreate the form with Pic controls on a report to do the same thing ?
          Would the code I use on the form differ for the report vastly ie using LoadPicture: Me.Controls(“img” & i).Picture = LoadPicture()

          I’ve been reading a lot today on the PaintPicture method, maybe this is the way to go.

        • #771729

          Charlotte
          The form I use to show images kind of represents a thumbnail view. (Basically picture controls, “Img1 thru to Img12”)

          Could I use a similar form to achieve my goal using the PrintForm method ?
          or
          Recreate the form with Pic controls on a report to do the same thing ?
          Would the code I use on the form differ for the report vastly ie using LoadPicture: Me.Controls(“img” & i).Picture = LoadPicture()

          I’ve been reading a lot today on the PaintPicture method, maybe this is the way to go.

        • #771744

          I’ve had a little play around and I can reproduce a form with a white background to look like a report.

          PrintForm method will be suffice from there, thanks for the starter.

          • #771807

            Ok, I’ve created the form with several image controls, the command:

            frmPrint.PrintForm, seems to print the form ok, but if I change the settings in the print dialog, nothing changes.
            I tried to set the dialog to print in Landscape as below in bold, but when pressing ok, the printout is still in portrait.
            If I change the quality setting, the same, the printout prints to whatever the default setting is.

              'CancelError is True.
              CmnDialogPrint.CancelError = True
              On Error GoTo ErrHandler
            
              CmnDialogPrint.ShowPrinter
              CmnDialogPrint.Orientation = cdlLandscape
              With CmnDialogPrint
                        frmPrint.PrintForm
                End With
            
              Exit Sub
            ErrHandler:
            
              ' User pressed Cancel button.
              MsgBox "Print Cancelled", , "Cancel"
          • #771808

            Ok, I’ve created the form with several image controls, the command:

            frmPrint.PrintForm, seems to print the form ok, but if I change the settings in the print dialog, nothing changes.
            I tried to set the dialog to print in Landscape as below in bold, but when pressing ok, the printout is still in portrait.
            If I change the quality setting, the same, the printout prints to whatever the default setting is.

              'CancelError is True.
              CmnDialogPrint.CancelError = True
              On Error GoTo ErrHandler
            
              CmnDialogPrint.ShowPrinter
              CmnDialogPrint.Orientation = cdlLandscape
              With CmnDialogPrint
                        frmPrint.PrintForm
                End With
            
              Exit Sub
            ErrHandler:
            
              ' User pressed Cancel button.
              MsgBox "Print Cancelled", , "Cancel"
            • #772080

              According to help, PrintForm [indent]


              Sends a bit-by-bit image of a Form object to the printer


              [/indent] That suggests to me that no matter what settings you use, the image is going to stay the same shape anyhow. Also PrintForm is a simple minded method that uses the control panel settings to pick a printer and print to it. I suspect you’re going to get the default settings for that printer regardless. I’ve run into similar problems using the Printer object in Office XP in Access.

            • #772124

              So does this mean I can’t change the printer preferences at all, by code or by selection ?

            • #772176

              I’ve now been able to control the printer Orientation to landscape but can’t find a setting for Quality.
              Does one exist or is this printer specific ?

              I can use :

              Printer.PrintQuality = vbPRPQmedium etc but still doesn’t work, maybe I haven’t inserted into my code correctly:

                 'CancelError is True.
                CmnDialogPrint.CancelError = True
                On Error GoTo ErrHandler
              
                CmnDialogPrint.ShowPrinter
                
                 If CmnDialogPrint.Orientation = cdlLandscape Then
                      Printer.Orientation = cdlLandscape
                          Else
                              Printer.Orientation = cdlPortrait
                                  End If
                 
                 With CmnDialogPrint
                  
                  Me.txtEst.Visible = False
                  Me.cmdFirst.Visible = False
                  Me.cmdPrev.Visible = False
                  Me.cmdNext.Visible = False
                  Me.cmdLast.Visible = False
                  Printer.PrintQuality = -3
                  frmPrint.PrintForm
                  End With
              
                Exit Sub
              ErrHandler:
              
                ' User pressed Cancel button.
                MsgBox "Print Cancelled", , "Cancel"
            • #772260

              I’ve only done it by retrieving the PrtDevMode properties and modifying them, so I can’t say for sure. I suspect there is no “Quality” property because that would vary with the printer driver.

            • #772414

              Thanks Charlotte for the help on this, you’ve been very helpful.

              Alas at the end of this I think I will have to source another way to accomplish this instead.
              I think I’ve seen some where a way to print a form without using “PrintForm” method, I think by copying to clipboard first.

              I’m off to Google, thanks again.

            • #772415

              Thanks Charlotte for the help on this, you’ve been very helpful.

              Alas at the end of this I think I will have to source another way to accomplish this instead.
              I think I’ve seen some where a way to print a form without using “PrintForm” method, I think by copying to clipboard first.

              I’m off to Google, thanks again.

            • #772177

              I’ve now been able to control the printer Orientation to landscape but can’t find a setting for Quality.
              Does one exist or is this printer specific ?

              I can use :

              Printer.PrintQuality = vbPRPQmedium etc but still doesn’t work, maybe I haven’t inserted into my code correctly:

                 'CancelError is True.
                CmnDialogPrint.CancelError = True
                On Error GoTo ErrHandler
              
                CmnDialogPrint.ShowPrinter
                
                 If CmnDialogPrint.Orientation = cdlLandscape Then
                      Printer.Orientation = cdlLandscape
                          Else
                              Printer.Orientation = cdlPortrait
                                  End If
                 
                 With CmnDialogPrint
                  
                  Me.txtEst.Visible = False
                  Me.cmdFirst.Visible = False
                  Me.cmdPrev.Visible = False
                  Me.cmdNext.Visible = False
                  Me.cmdLast.Visible = False
                  Printer.PrintQuality = -3
                  frmPrint.PrintForm
                  End With
              
                Exit Sub
              ErrHandler:
              
                ' User pressed Cancel button.
                MsgBox "Print Cancelled", , "Cancel"
            • #772125

              So does this mean I can’t change the printer preferences at all, by code or by selection ?

            • #772081

              According to help, PrintForm [indent]


              Sends a bit-by-bit image of a Form object to the printer


              [/indent] That suggests to me that no matter what settings you use, the image is going to stay the same shape anyhow. Also PrintForm is a simple minded method that uses the control panel settings to pick a printer and print to it. I suspect you’re going to get the default settings for that printer regardless. I’ve run into similar problems using the Printer object in Office XP in Access.

        • #771745

          I’ve had a little play around and I can reproduce a form with a white background to look like a report.

          PrintForm method will be suffice from there, thanks for the starter.

      • #771721

        You can create a recordset in memory using ADO, Dave. That might be your best option in this case. Build an array of the data you want to display in the report, then loop through its elements and use the .AddNew method of the ADO recordset for each record and use the Array() function to build a paramarray of the individual fields for each record. It’s a little complicated to describe (and a bit to do) but it will convert an array of structured data into a recordset, which you can then use to populate a form or report.

    • #771539

      I’ve checked again this morning and every example I can find relates to the datareport having a recordset, table or other source from databases.
      Does this have to be so and can’t a report be based on a folders content or VB form list control using a path to the folder ?

    Viewing 1 reply thread
    Reply To: Reply #772176 in DataReport without DataSource (VB6)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel