Results 1 to 13 of 13

Thread: Scrolling a form

  1. #1

    Thread Starter
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Don't give up

    Don't give up. Try this: Change AutoRedraw property of the form to True, then use this code:
    Code:
    Option Explicit
    Private m_intLastPos As Integer
    
    Private Sub Scroll()
        Dim i As Integer
        
        Me.Cls
        For i = m_intLastPos To VScroll1.Max
            Me.Print i
        Next
        
        m_intLastPos = VScroll1.Value
    End Sub
    
    
    Private Sub Form_Load()
        VScroll1.Max = 100
        Call Scroll
    End Sub
    
    Private Sub Form_Resize()
        With VScroll1
            .Top = 0
            .Height = ScaleHeight
            .Left = ScaleWidth - .Width
        End With
    End Sub
    
    Private Sub VScroll1_Change()
        Call Scroll
    End Sub

  2. #2
    Lively Member
    Join Date
    Jan 2000
    Location
    usa
    Posts
    100

    Thumbs up

    Thanks Serge, worked great.
    But how do I get rid of the scrollbar blinking?

  3. #3

    Thread Starter
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    I don' think there's a direct way of doing it in VB, but you can use Windows Common Controls 2 which has FlatScrollBar control which is not flashing.

  4. #4
    Lively Member
    Join Date
    Jan 2000
    Location
    usa
    Posts
    100
    One more thing.
    I have got the form to scroll, but when I put in the
    following code, it will not. Why?

    code:
    Sub Scroll()
    Me.Cls
    With rst
    While Not rst.EOF
    'display fields
    Wend
    end with
    m_intLastPos = VScroll1.Value
    End Sub

  5. #5

    Thread Starter
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Why are you trying to show records from the database on the form when there are plenty conttols that you can use to do that???

  6. #6
    Lively Member
    Join Date
    Jan 2000
    Location
    usa
    Posts
    100
    Thanks for your quick reply Serge, but let me explain
    what I'm trying to do, and I'll appreciate your continued help.
    I'm giving the user the option of either spooling a report
    to the screen or the printer.
    I populate a recordset with fields from a db using a SQL
    query, of which I would like to display on the screen.
    That's where the code for displaying the query to the screen
    comes in. So, if I'm going about it the wrong way, please
    let me know, and I'm looking forward to your suggestions.

  7. #7

    Thread Starter
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    VB comes with Crystal Reports that you can use. It is really easy to use. Basically, you create a template of the report and then call the report from VB.

  8. #8
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    What about a grid

    What if you loaded your data into a grid? This would eliminate the form scroll necessity since the grid has the scroll bar. You could then print the contents of the grid using VB Printer.Print ...

    Just my opinion.
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  9. #9

    Thread Starter
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    The only problem with the grid is that you have to take care of the printing functionality manually, which can be a big piece of work, where with Crystal Reports it's all built-in.

  10. #10
    Lively Member
    Join Date
    Jan 2000
    Location
    usa
    Posts
    100
    I hope I'm not asking too much, but how do I do that?

  11. #11
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Do what?

    What is it you want to do?
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  12. #12
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    If you want...

    If you want to know how to add data to a grid...

    You can loop each record in your database then,

    mydata _
    = rst!EmployeeFull _
    & vbTab & Rst!PCSNO _
    & vbTab & rst!Classification _
    & vbTab & Format(SUN, "#0.00") _
    & vbTab & Format(MON, "#0.00") _
    & vbTab & Format(TUE, "#0.00") _
    & vbTab & Format(WED, "#0.00") _
    & vbTab & Format(THU, "#0.00") _
    & vbTab & Format(FRI, "#0.00") _
    & vbTab & Format(SAT, "#0.00") _

    frmWeeklyPayroll.MSFlexGrid1.AddItem mydata

    Just an example...
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  13. #13
    Lively Member
    Join Date
    Jan 2000
    Location
    usa
    Posts
    100
    Thanks for you help guys, I have finally got it working.
    I basically loaded the records from a rst into a array,
    and then print the array to the form.
    The only problem now is that the scrollbars blink, and
    to a lesser degree, the form will scroll with less than
    one page of text.

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