Form Locking

agehoops

Registered User.
Local time
Today, 12:16
Joined
Feb 11, 2006
Messages
351
Is there a way of locking the form of any use until the record has completely loaded?

Thanks
 
You can save the form with "AllowEdits = No" and
in the On Open event set use "Me.AllowEdit = True" to turn on editing.

But, the more important question is what is happening with your form (or with the user) that you need to lock the form?
 
Well basically the form has a picture of the member of staff of each record which is working fine, however when the user skips to the next record and then skips again and again quite quickly, it slows the whole thing down as it tries to load the next picture each time, and it causes access to simply hang and forces the user to shut down. What I was hoping to do, was when the user skips to the next or previous record, it locks the form so they cannot do it again, until that record and picture has completely finished loading, thus stopping it from freezing access??
 
So you want your application to seem sluggish? How about setting up a timer event to start loading after some given time? Reset the timer every time the user skips to the next record. That will give your form some zip and still load the picture if the user pauses long enough.
 
Nah i don't want it to be sluggish, just prevent it from freezing. It's if the user skips just one record, but it's when the press the skip button a couple of times, and it's basically just the image that is causing it to freeze. I could put the picture on a separate popup form but i'd rather have it all on the one form just without the problems :(
 
If you are using the native nav buttons, I doubt you can stop the rapid scanning. You don't like the timer idea?
 
I've got custom buttons on the form to skip the records.
With the timer, do you mean to load the picture after a certain amount of time? so that the rest of the record loads quickly, and THEN it loads the picture after the timer?
 
You've got it. You actually load the picture in the timer event rather than the Current event of the form. The Current event just turns on the timer by setting the Timer interval (maybe about 500 - 1/2 second). The timer event just sets the timer interval to zero (turning off the event) and loads the current picture.
 
Oh right ok, yea that would probably be perfect. How would you go about doing that. I know how to put code into the Timer even and set the timers interval to whatever time i need but how do i get the code to run the timer interval and reset it without it constantly running the timer all the time?
 
I think we'll need a public count down integer. The timer event only runs when the TimerInterval is *not* zero. So we decide to start loading the picture after a 1/2 second pause by the user. The current event sets the TimerInterval to 100 and the public count down integer to 5. The timer now runs every 10th of a second (100 MS) and decrements the public count down integer. If the count down reaches 0 then the the timer event sets the TimerInterval to 0 to stop any further timer events and loads the current picture.
 
Ok i'm getting slightly confused now sorry.

So setting the TimerInterval, is that just a normal variable? or the system timer?
I assume the countdown integer is also a variable? When you say public, do you mean just declare as public, within the form, or in a separate module?

Then i just get confused from that point on? Sorry
 
Declare the CountDown integer in your form's class code before any procedures. It is public only for this form. The TimerInterval is a form property and can be referenced with Me.TimerInterval. So the top of your form's class module (code window) will be:
Code:
Option Compare Database
Option Explicit

Public  CountDown As Integer
Then your current event code is simply
Code:
CountDown = 5
Me.TimerInterval = 100
The Timer event is:
Code:
Private Sub Form_Timer()
If CountDown <> 0 Then
    '-- CountDown is still running
    CountDown = CountDown - 1
Else
   '-- Time out
   '--Turn off the Timer Interrupts
   Me.TimerInterval = 0
   '
   '-- Now load your picture code goes here!
   '
End If
Post back if you need additional assistance.
 
Hiya, thanks so much! Seemed to work perfectly :D Was becoming a complete pain. The only slight glitch with this is that for that half second it keeps the old picture there when you change records but this one I should be able to solve :)

Thanks again
Aidy
 
Thanks for posting back. I was wondering how that worked. You might just clear the picture in the Current event so the user can tell something is happening. You can play with the timeout for the best results. Maybe 500MS is too long.
 
Yea i'll fiddle around with that. I may do what i'm currently doing (only recently) where as if there is no picture to be linked, the picture box is hidden, and the embedded picture is visible (as it is underneath) so I may just say for that half second to hide it, then if there is a picture to be linked, make it visible again, if not keep it hidden (should be doing that anyway) just have to make it hidden on the timer. But yea everything works well, i'll find the best times but a half second seems pretty good. It stops it hanging for sure :)
 

Users who are viewing this thread

Back
Top Bottom