709-218-7927

The Landfall Garden House

60 Canon Bayley Road

CANADA A0C 1B0

CPRGreaves@gmail.com

Home

Christopher Greaves

Locating today's calls

We will now make use of our expertise in (a) building Command Buttons and (b) our inherited values for the FollowUp field.

Build a Command Button, its name will be cmd_ Current and its caption can be "Current". The purpose of this button will be to throw up on the screen the most current record in our table. This answers the question "Who am I due to speak with today, or should have spoken with yesterday? Who deserves a telephone call right now?".

Private Sub cmdCurrent_Click()
Me.OrderBy = "FOLLOWUP DESC"
Me.OrderByOn = True
Me.Filter = "FOLLOWUP <= '" & Format(Now(), "YYYYMMDD") & "'"
Me.FilterOn = True
DoCmd.GoToRecord , , acFirst
End Sub

The difference between the current button and the previous button is in the sequence of presentation. Note that we have added "DESC", to signal "Descending Sequence" in our filter string. In both cases we are asking for records that are due for follow up today or sooner. In the case of "oldest" we want to see the lowest value in the sequence; in the case of "current" we want to see the highest value in the sequence. By ordering the records to be sorted in descending sequence, and then asking to be taken to the first of that sequence, we will be presented with the highest-valued, that is, the date closest to today's date.

Locating all records

If you want to build a Command Button to drop all filters and display all the records do so. Try using the code shown below:

Private Sub cmd_All_Click()
DoCmd.ShowAllRecords
Me.OrderBy = "FOLLOWUP"
Me.OrderByOn = True
DoCmd.GoToRecord , , acFirst
End Sub

7092187927 CPRGreaves@gmail.com

Bonavista, Friday, December 04, 2020 5:52 PM

Copyright © 1996-2020 Chris Greaves. All Rights Reserved.