Button for Due Dates (1 Viewer)

andreab13

New member
Local time
Today, 03:46
Joined
Mar 21, 2019
Messages
3
Hi everyone,

I followed a tutorial to do a custom search. Works great...for the most part. When my form opens, I already have it set to show me due dates due in the next 60 days. Once I click "Clear", it clears everything...so it's just blank. If there is a way to set it back to the original state of my form, that would be great.

The other thing I would really like is to have a button that I can click that will automatically show me due dates in the next 30 days, 60 days, and 90 days. I do not know code well enough to make this work on my own.

Any help with this? Thank you in advance!

The following is my custom search code just for reference.

Code:
Private Sub Command30_Click()
' Search button
Call Search
End Sub
Sub Search()
Dim strCriteria, task As String

Me.Refresh
If IsNull(Me.DateFrom) Or IsNull(Me.DateTo) Then
    MsgBox "Please enter the date range", vbInformation, "Date Range Required"
    Me.DateFrom.SetFocus
Else
    strCriteria = "([Follow] >= #" & Me.DateFrom & "# And [Follow] <= #" & Me.DateTo & "#)"
    task = "select * from Services where (" & strCriteria & ") order by [Follow]"
    DoCmd.ApplyFilter task
End If
End Sub

Private Sub Command31_Click()
Dim task As String

    Me.DateFrom = Null
    Me.DateTo = ""
        task = "select * from Services where Follow is null"
    DoCmd.ApplyFilter task
End Sub

Private Sub Command32_Click()
Dim task As String

    Me.DateFrom = Null
    Me.DateTo = ""
        task = "select * from Services order by [Follow]"
    Me.RecordSource = task

End Sub
 

Ranman256

Well-known member
Local time
Today, 06:46
Joined
Apr 9, 2015
Messages
4,339
in a form put a box ,txtDays. fill it with 30, 60,etc.
in the query to pull data, use the form to get the time range.

all those who's [due date] < N days
query:
select * from table where [DueDateFld] <= DateAdd("d",forms!fMyFormtxtDays,Date())
 

Users who are viewing this thread

Top Bottom