Results 1 to 17 of 17

Thread: Print, MSHFlexgrid.

  1. #1

    Thread Starter
    Lively Member yanty's Avatar
    Join Date
    Nov 2005
    Location
    Singapore
    Posts
    83

    Print, MSHFlexgrid.

    Hi all,

    I know that to print a form, we use :

    VB Code:
    1. form1.printform

    But sumtimes if there are no printers connected, there will error on the program. Is that normal or there is a way to solve it? I tried printing once and the paper shows alot of empty space. Can we print the form and it fits the whole page of the paper?

    Another thing is that during runtime, my mshflexgrid only hilights 2 columns instead of one row. I tried to change the properties but to no avail.
    Attached Images Attached Images  

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Print, MSHFlexgrid.

    Quote Originally Posted by yanty
    But sumtimes if there are no printers connected, there will error on the program.
    Error trap the printform routine.

  3. #3

    Thread Starter
    Lively Member yanty's Avatar
    Join Date
    Nov 2005
    Location
    Singapore
    Posts
    83

    Re: Print, MSHFlexgrid.

    How do we do dat?

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Print, MSHFlexgrid.

    Use an error trap like this

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub PrintForm()
    4.   On Error GoTo Print_Error
    5.     Form1.PrintForm
    6.   Exit Sub
    7. Print_Error:
    8.   On Error GoTo 0
    9.   MsgBox "Printer not available or is Offline"
    10. End Sub

  5. #5

  6. #6

    Thread Starter
    Lively Member yanty's Avatar
    Join Date
    Nov 2005
    Location
    Singapore
    Posts
    83

    Re: Print, MSHFlexgrid.

    2 columns as shown in my attached image. only after i click on the row, the whole row will be highlighted.

  7. #7

    Thread Starter
    Lively Member yanty's Avatar
    Join Date
    Nov 2005
    Location
    Singapore
    Posts
    83

    Re: Print, MSHFlexgrid.

    Quote Originally Posted by dglienna
    Use an error trap like this

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub PrintForm()
    4.   On Error GoTo Print_Error
    5.     Form1.PrintForm
    6.   Exit Sub
    7. Print_Error:
    8.   On Error GoTo 0
    9.   MsgBox "Printer not available or is Offline"
    10. End Sub
    Isit we put this code under the command button we click for printing or do we put a call function PrintForm under the the command button?

  8. #8
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Print, MSHFlexgrid.

    Call the function from the print button, but put the error trap in the function itself, where you open the file.

  9. #9

    Thread Starter
    Lively Member yanty's Avatar
    Join Date
    Nov 2005
    Location
    Singapore
    Posts
    83

    Re: Print, MSHFlexgrid.

    VB Code:
    1. Private Sub cmdPrint_Click()
    2.  
    3. Call PrintForm
    4.  
    5. End Sub
    6.  
    7. Private Sub PrintForm()
    8.   On Error GoTo Print_Error
    9.     Form1.PrintForm
    10.   Exit Sub
    11. Print_Error:
    12.   On Error GoTo 0
    13.   MsgBox "Printer not available or is Offline"
    14. End Sub

    I tried this but it states member already exist in object module.

  10. #10
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Print, MSHFlexgrid.

    Which line generates the error?

  11. #11

    Thread Starter
    Lively Member yanty's Avatar
    Join Date
    Nov 2005
    Location
    Singapore
    Posts
    83

    Re: Print, MSHFlexgrid.

    private sub printform

  12. #12
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Print, MSHFlexgrid.

    PrintForm is a reserved word in VB, so you can't call your sub that.
    If you have this code in the form itself, you can just call
    VB Code:
    1. Form1.PrintForm

    like this:
    VB Code:
    1. PrintForm

    Call your sub SendToPrinter or something like that, and change the call statement.

  13. #13
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: Print, MSHFlexgrid.

    i know its kinda out of topic but how about using a data report to print your data rather than directly printing the form. it would be a lot more easier than printing a form

    this is only a suggestion okay

  14. #14

    Thread Starter
    Lively Member yanty's Avatar
    Join Date
    Nov 2005
    Location
    Singapore
    Posts
    83

    Re: Print, MSHFlexgrid.

    data report? how is that like?

  15. #15
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: Print, MSHFlexgrid.

    when in preview mode, it looks like a piece of bond paper with the data that you place on it or on your database table.

  16. #16
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Print, MSHFlexgrid.

    Quote Originally Posted by yanty
    data report? how is that like?
    If you are interested in the Data Report, take a look at these.

    Create Reports Using The Data Report
    Data Report Tutorial
    Data Report Demo

  17. #17

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width