Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to run a report once a day only?

Status
Not open for further replies.

JojoKa

Technical User
Mar 28, 2006
18
US
Hi,
How can i allow a user to ran a report (using a command button in a form) ONLY once a day?

Thanks in advance

Joseph
 
Probably by building a table
[tt]
tblRunDate

LastRunDate
[/tt]

Code:
Sub cmdReport_Click()
    Dim LastRunDate As Date
    Dim AllowReport As Boolean
    LastRunDate = DMax("LastRunDate", "tblRunDate")
    If IsNull(LastRunDate) Then
        AllowReport = True
        CurrentDb.Execute "INSERT INTO tblRunDate (LastRunDate) " & _
                          "VALUES(#" & Date & "#)"
    ElseIf LastRunDate < Date Then
        AllowReport = True
        CurrentDb.Execute "UPDATE tblRunDate " & _
                          "SET LastRunDate = #" & Date & "#"
    Else
        AllowReport = False
    End If

    If AllowReport Then
       [COLOR=Green]' Run the Report[/color]
    Else
       MsgBox "Report has already been run today."
    End If

End Sub

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top