Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 05-17-2019, 10:36 AM   #1
andreab13
Newly Registered User
 
Join Date: Mar 2019
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
andreab13 is on a distinguished road
Button for Due Dates

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

andreab13 is offline   Reply With Quote
Old 05-17-2019, 10:58 AM   #2
Ranman256
Newly Registered User
 
Join Date: Apr 2015
Location: KY,USA
Posts: 3,340
Thanks: 0
Thanked 737 Times in 722 Posts
Ranman256 will become famous soon enough Ranman256 will become famous soon enough
Re: Button for Due Dates

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())
Ranman256 is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Use a form to filter dates on a query, or leave blank to show all dates ObiBenKenobi Queries 9 12-31-2014 10:28 AM
Add future dates on button click veg_racer Forms 1 01-14-2014 04:25 AM
Button to tranfer dates to a combo box anchamal Forms 1 02-02-2011 10:57 AM
Filling From & To dates with button Henley12 Forms 1 11-12-2007 12:27 PM
Button Up and Down to select dates lcann Forms 1 07-16-2007 10:19 PM




All times are GMT -8. The time now is 04:30 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World