Bob Gajewski
bob at renaissancesiding.com
Tue Feb 11 14:57:00 CST 2003
Charles I realize that. The answer proposed by Arthur and my alternate both use MsgBox, as the situation requires user decision. I was questioning whether there was an appreciable difference between using MsgBox then checking for vbNo versus "If vbNo = MsgBox ..." . Thanks, Bob Gajewski On Tuesday, February 11, 2003 15:39 PM, Wortz, Charles [SMTP:CWortz at tea.state.tx.us] wrote: > Bob, > > Whenever you have a MsgBox() you have to wait for the user response, > which is measured in seconds. Think of the thousands of lines of your > code that could be running while you await the user response > > Charles Wortz > Software Development Division > Texas Education Agency > 1701 N. Congress Ave > Austin, TX 78701-1494 > 512-463-9493 > CWortz at tea.state.tx.us > (SELECT * FROM users WHERE clue > 0) > > > -----Original Message----- > From: Bob Gajewski [mailto:bob at renaissancesiding.com] > Sent: Tuesday 2003 Feb 11 14:26 > To: 'accessd at databaseadvisors.com' > Subject: RE: [AccessD] Using DateDiff function CORRECTED QUESTION > > CORRECTION > > Arthur > > (Almost) totally unrelated question, but I imagine you know the answer > Which is more efficient? > > ************************************************************** > Private Sub Command20_Click() > If DateDiff("h", Now, LastRun()) <= 15 Then > If vbNo = MsgBox("You've already updated the records today." & vbCrLf > & _ > "Are you sure that you want to update them again?", vbYesNo + > vbQuestion, "Alert") > Exit Sub > Else > DoCmd.RunMacro "GetRates" > End If > End If > End Sub > ************************************************************** > > or your response to Oleg? > > I'm desperately trying to streamline my code for processing speed, and I > would appreciate any thoughts you have on this > > TIA, > Bob Gajewski > > > On Tuesday, February 11, 2003 15:00 PM, Arthur Fuller > [SMTP:artful at rogers.com] wrote: > > Yet another opportunity for me to praise static functions :-) Put this > > > into a public module: > > > > Static Function LastRun() as Date > > Dim dtNow as Date > > If IsNull(dtNow) Then > > dtNow = Now() > > End If > > LastRun = dtNow > > End Function > > > > Now call this function from your click: > > > > Private Sub Command20_Click() > > Dim Andy > > If DateDiff("h", Now, LastRun()) <= 15 Then > > Andy = MsgBox("You've already updated the records today" & vbCrLf & _ > > "Are you sure you wish to update again?", vbYesNo, "alert") > > If Andy = vbNo Then > > Exit Sub > > End If > > End If > > DoCmd.RunMacro "GetRates" > > End Sub > > > > Or, perhaps better, in the OnCurrent event of the form, set the > > availability of the button and forget the "You bungling user" message > > :-) > > > > Command20.Enabled = DateDiff("h", Now, LastRun()) > 15 > > > > Which of course poses problems if the user is likely to have the form > > open on the same record for hours and hours, but if that is a > > possibility you can put the line above into its own function and call > > that function from a timer Hth, > > Arthur > > > _______________________________________________ > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > > .