[AccessD] Using DateDiff function

Oleg_123 at xuppa.com Oleg_123 at xuppa.com
Thu Feb 13 05:45:00 CST 2003


hey guys; so how do I save settings to my form design that  Imade at
runtime ?

> I think I am getting somewhere now; exsept that I can't remember how to
> save the design settings in runtime. I think we learned it, but just
> can't recall...
>
> Private Sub Command20_Click()
> Dim Andy
> Dim Update
>
> 'lblUpdate.Caption = Now 'when is first used
> Update = lblUpdate.Caption
>
>
> If DateDiff("h", Now, Update) <= 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
> DoCmd.RunMacro "GetRates"
> lblUpdate.Caption = Now()
>
> End Sub
>
>
>
>> 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
>>
>> -----Original Message-----
>> From: accessd-admin at databaseadvisors.com
>> [mailto:accessd-admin at databaseadvisors.com] On Behalf Of
>> Oleg_123 at xuppa.com Sent: February 11, 2003 1:53 PM
>> To: accessd at databaseadvisors.com
>> Subject: [AccessD] Using DateDiff function
>>
>> Hey, I am trying to make sure a user doesn'y click on  same button
>> twice in one day by mistake. I wrote this; doesn't work caz LastRun
>> keeps getting redefined if it starts over. Maybe I should an invisible
>> label to store latest update date and then check against the label ?
>>
>> -------------------------------------------------------
>> Dim LastRun
>>
>> Private Sub Command20_Click()
>> Dim Andy
>>
>> If DateDiff("h", Now, LastRun) <= 15 Then
>> Andy = MsgBox("You've alredy 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"
>>
>> LastRun = Now
>> End Sub
>>
>>
>> -----------------------------------------
>> Send a Xuppa Valentine to Your Sweetheart today!
>> http://www.xuppa.com/greet/
>>
>>
>> _______________________________________________
>> AccessD mailing list
>> AccessD at databaseadvisors.com
>> http://databaseadvisors.com/mailman/listinfo/accessd
>> Website: http://www.databaseadvisors.com
>>
>> _______________________________________________
>> AccessD mailing list
>> AccessD at databaseadvisors.com
>> http://databaseadvisors.com/mailman/listinfo/accessd
>> Website: http://www.databaseadvisors.com
>
>
>
>
>
>
>
> -----------------------------------------
> Send a Xuppa Valentine to Your Sweetheart today!
> http://www.xuppa.com/greet/
>
>
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com



-----------------------------------------
Send a Xuppa Valentine to Your Sweetheart today!
http://www.xuppa.com/greet/





More information about the AccessD mailing list