By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
463,206 Members | 595 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 463,206 IT Pros & Developers. It's quick & easy.

refresh screen during scrolling

P: 68

I'm trying to emulate, within access, the gantt chart timeline / task planner aspects of ms project. Creating the chart on the form has been easy enough; I use a series of unbound text boxes in the header to show the week numbers, with correlating unbound text boxes in the detail section of a continuous form to calculate a series of values for each task which, where these match the value in the header text box will change the colour of the detail box using conditional formatting.

The planner only shows 3 months worth of project time on the form, so to make it 'dynamic' i.e. can span 2 or 3 years worth of project life, I use an activex scroll bar control to set the week number of the first week in the first text box, then the other 12 text boxes (weeks in the displayed quarter) calculate off that.

All of this is slightly besides the point but it might help you understand what it is I'm trying to acheive;

my problem is that I would like all the text boxes to recalculate and/or get a screen refresh on each incremental change when I hold down the scroll bar buttons, i.e. to scroll. This would mean that the form would then look and work exactly like project. At the moment it'll refresh once I stop scrolling, but not during the scroll. however, the value in the first text box, which is set by the scroll bar, does update during scrolling so I'm sure this must be possible. I've tried playing around with the various events of the scroll bar and the text boxes but this doesn't get me anywhere.

It feels like I'm either missing something obvious or going down a blind alley, i.e. I could acheive this quite easily through using a different control or approach. Does anyone have any ideas?

Nov 12 '08 #1
Share this Question
Share on Google+
7 Replies

Expert 2.5K+
P: 2,653
Hello, Kevin.

Try to use DoEvents command.

Nov 12 '08 #2

P: 68
Hi Fishval

that doesn't seem to work. can I check that I'm coding this right?

Expand|Select|Wrap|Line Numbers
  1. Private Sub ScrollBar1_Change()
  2. On Error GoTo proc_error
  3. Dim ScrollVal As Integer
  4. Dim DateFactor As Integer
  6. ScrollVal = Int(Me.ScrollBar1.Value)
  8. Select Case ScrollVal
  9. Case 52
  10. DateFactor = 0
  11. Me.txtWk1 = RefDate
  12. Case Is < 52
  13. DateFactor = (52 - ScrollVal) * 7
  14. Me.txtWk1 = RefDate - DateFactor
  15. Case Is > 52
  16. DateFactor = (ScrollVal - 52) * 7
  17. Me.txtWk1 = RefDate + DateFactor
  18. End Select
  19. Me.Repaint
  20. DoEvents
  22. proc_error:
  23. GoTo proc_exit
  25. proc_exit:
  26. Exit Sub
  28. End Sub
It actually doesn't make any difference whether I use refresh or repaint, or whether this is before or after doevents. If you're certain that doevents is the solution I'll persist.

Nov 13 '08 #3

Expert 5K+
P: 8,748
  1. I'm a little rusty on the ScrollBar Control, but if you a User to be able to see the changes in the Value Property while dragging the Button, you need to place code in the Scroll() Event.
  2. Consequently, I would imagine that if you wanted the Screen Display to 'catch up', you would place the DoEvents Statement here.
  3. If the difference between the Min and Max values is large, you may wish to execute DoEvents at periodic Intervals, such as:
    Expand|Select|Wrap|Line Numbers
    1. Private ScrollBarName_Scroll(<not sure of Argument(s)>)
    2. Static lngCounter As Long
    4. lngCounter = lngCounter + 1
    6. If lngCounter Mod 1000 = 0 Then
    7.   DoEvents
    8. End If
    9. End Sub
  4. Take all this with a grain of salt, since I haven't programmed Scroll Bars in awhile, but do let us know how you make out.
Nov 13 '08 #4

P: 68
Sadly that doesn't work either. Refreshing does have an effect in so far that the screen will flicker as the value changes, but at best the screen will white-out within the affected area the repaint once I release the mouse button. I'm wondering whether I might be able to solve it by using a mousedown event on the form coupled with timer and an on_click on a dummy button. I don't know enough about scroll bars to know what I should be able to get them to do but it feels like the mousedown situation interferes with any attempt to interrupt the looping which must be taking place.

Nov 13 '08 #5

Expert 5K+
P: 8,748
Not sure what the problem is, if I send you my E-Mail Address in a Private Message, would you be willing to send me the DB so that I may have a look at it first hand?
Nov 13 '08 #6

P: 68
that's very kind of you, yes of course. do you need my private email address?

Nov 13 '08 #7

Expert 5K+
P: 8,748
do you need my private email address?
No, I'll obtain it when you E-Mail me the Database as an Attachment. I'll send you a Private Message shortly with the Address.
Nov 13 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.