Prev: How to import data from Excel that has password protected shee?
Next: Changing data in Before Update
From: Owl on 16 Mar 2010 15:25 I could have sworn I put this in, but no Search is revealing it, so here it is (again?). I have created the following Event Procedure for On Timer (the Timer Interval is set to 10000): Private Sub Form_Timer() 'On the forms timer event close the start-up form DoCmd.Close acForm, "Diana'sStartUpForm" 'Open up the main switchboard form when the start-up form closes DoCmd.OpenForm "Switchboard" End Sub I have subsequently created a Pause Button called Pause This Screen with the following Event Procedure (which I don't understand but copied it from the Internet and modified it where I THOUGHT it needed to be modified to pause for 30 seconds): Private Sub Pause_this_screen_Click() Dim PauseTime, Start, Finish, TotalTime If (MsgBox("Pause this screen", _ 4)) = vbYes Then PauseTime = 30000 ' Set duration. Start = Timer ' Set start time. Do While Timer < Start + PauseTime DoEvents ' Yield to other processes. Loop Finish = Timer ' Set end time. TotalTime = Finish - Start ' Calculate total time. MsgBox "Paused for " & TotalTime & " seconds" Else End End If End Sub My first question is: What does the _4 mean? My second question is: What do I need to do to modify the screen to pause for 30 seconds? My third question is: Does that mean it will pause for 30 seconds IN ADDITION TO – or INSTEAD OF - the original 10 seconds as set on the timer? I have added a “Continue to Main Menu” button which overrides the pause, but would like the pause to be long enough to make the user have control of how much time is spent on the StartUp screen. Thank you for any help Owl
From: Mike B on 16 Mar 2010 16:15 The code you copied is shown in the Access Help File, but it is more appropriate to VBScript as the variables are not typed, thence they are Variants. The 4 is the constant for the type of msgbox. If you look at the msgbox function in help, you will see a list of constants like vbQuestion, vbInformation, etc. You might have better luck with the following as the timer function returns Seconds and tenths, not milliseconds, so your pause time would be 30 not 30000. Since the Timer is a function, I have displayed it as Timer() for clarity. You can mix the constants in the MsgBox function / procedure to set the type of message box, the buttons used and which button will be the default button, all found in the helpfule. Private Sub Pause_this_screen_Click() Dim PauseTime As Single Dim Start As Integer Dim Finish As Integer Dim TotalTime As Integer 'Debug.Print CStr(Timer()) If (MsgBox("Pause this screen", vbYesNo + vbQuestion, "Pause Screen")) = vbYes Then PauseTime = 30 ' Set duration. Start = Timer() ' Set start time. Do While Timer() < (Start + PauseTime) DoEvents ' Yield to other processes. Loop Finish = Timer() ' Set end time. TotalTime = Finish - Start ' Calculate total time. MsgBox "Paused for " & TotalTime & " seconds" Else End If End Sub "Owl" <Owl(a)discussions.microsoft.com> wrote in message news:0BDFA1EC-48A4-4139-82FF-48DE650A45A9(a)microsoft.com... >I could have sworn I put this in, but no Search is revealing it, so here it > is (again?). > > I have created the following Event Procedure for On Timer (the Timer > Interval is set to 10000): > > Private Sub Form_Timer() > > 'On the forms timer event close the start-up form > DoCmd.Close acForm, "Diana'sStartUpForm" > 'Open up the main switchboard form when the start-up form closes > DoCmd.OpenForm "Switchboard" > > End Sub > > I have subsequently created a Pause Button called Pause This Screen with > the > following Event Procedure (which I don't understand but copied it from the > Internet and modified it where I THOUGHT it needed to be modified to pause > for 30 seconds): > > Private Sub Pause_this_screen_Click() > Dim PauseTime, Start, Finish, TotalTime > If (MsgBox("Pause this screen", _ > 4)) = vbYes Then > PauseTime = 30000 ' Set duration. > Start = Timer ' Set start time. > Do While Timer < Start + PauseTime > DoEvents ' Yield to other processes. > Loop > Finish = Timer ' Set end time. > TotalTime = Finish - Start ' Calculate total time. > MsgBox "Paused for " & TotalTime & " seconds" > Else > End > End If > > End Sub > > My first question is: What does the _4 mean? > My second question is: What do I need to do to modify the screen to pause > for 30 seconds? > My third question is: Does that mean it will pause for 30 seconds IN > ADDITION TO - or INSTEAD OF - the original 10 seconds as set on the timer? > > I have added a "Continue to Main Menu" button which overrides the pause, > but > would like the pause to be long enough to make the user have control of > how > much time is spent on the StartUp screen. > > Thank you for any help > > Owl
From: John W. Vinson on 16 Mar 2010 17:04 On Tue, 16 Mar 2010 16:15:00 -0400, "Mike B" <mDotByerley(a)VerizonDottieNettie> wrote: > the timer function returns >Seconds and tenths, not milliseconds ummm... Mike, I think you're mistaken; it is milliseconds: from the VBA Help - You can use the TimerInterval property to specify the interval, in milliseconds, between Timer events on a form. Read/write Long. -- John W. Vinson [MVP]
From: Mike B on 16 Mar 2010 22:49 It must default to what I said. I tested it before posting. I haven't used the timer function in VBA to tell the truth, for a very long time. The first time I ran it I had the time to run set to 30000 expecting milliseconds and it never timed out, so I added a couple debug.prints to see what was happening, and it was in seconds and tenths, FWIW. "John W. Vinson" <jvinson(a)STOP_SPAM.WysardOfInfo.com> wrote in message news:nfsvp5l7eghitjl8evvni629o77pj12s50(a)4ax.com... > On Tue, 16 Mar 2010 16:15:00 -0400, "Mike B" > <mDotByerley(a)VerizonDottieNettie> > wrote: > >> the timer function returns >>Seconds and tenths, not milliseconds > > ummm... Mike, I think you're mistaken; it is milliseconds: from the VBA > Help - > > You can use the TimerInterval property to specify the interval, in > milliseconds, between Timer events on a form. Read/write Long. > > -- > > John W. Vinson [MVP]
From: Mike B on 17 Mar 2010 07:50 Further, the timer function isn't the same as the timer object. Just for Sh*ts and Giggles, I did look in the AC2007 help and under Remarks: Remarks In Microsoft Windows the Timer function returns fractional portions of a second. On the Macintosh, timer resolution is one second. The timer function is what you would use in a module where it isn't hosted by a form or report. If you want finer resolution in a module, then you can go to the windows API and use the multimedia timer. I use it all the time in Delphi. If you want just milliseconds, you can also use the API Sleep() function. "John W. Vinson" <jvinson(a)STOP_SPAM.WysardOfInfo.com> wrote in message news:nfsvp5l7eghitjl8evvni629o77pj12s50(a)4ax.com... > On Tue, 16 Mar 2010 16:15:00 -0400, "Mike B" > <mDotByerley(a)VerizonDottieNettie> > wrote: > >> the timer function returns >>Seconds and tenths, not milliseconds > > ummm... Mike, I think you're mistaken; it is milliseconds: from the VBA > Help - > > You can use the TimerInterval property to specify the interval, in > milliseconds, between Timer events on a form. Read/write Long. > > -- > > John W. Vinson [MVP]
|
Next
|
Last
Pages: 1 2 Prev: How to import data from Excel that has password protected shee? Next: Changing data in Before Update |