-
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
-
Thanks Serge, worked great.
But how do I get rid of the scrollbar blinking?
-
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.
-
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
-
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???
-
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. :)
-
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.
-
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.
-
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.
-
I hope I'm not asking too much, but how do I do that?
-
Do what?
What is it you want to do?
-
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...
-
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.