Code Samples for Businesses, Schools & Developers

Screenshots

Click the image to view a larger version

DayTracker

Version 1.0                   Last Updated 25 Jun 2017                   Approx 0.5 MB (zipped)


Someone asked me to create a simple day tracker for counting the number of days since an event or until an event

I thought I'd upload it here in case its of any use to anyone else
There's nothing at all 'fancy' about it.

However anyone unfamiliar with the syntax used for easily coding multiple repeated events may find this worth adapting for other purposes

For example:

Private Sub InitialiseForm()

   'clear previous values
   For I = 1 To 12
       Me("lblDays" & I).Caption = ""
       Me("lblDays" & I).Visible = False
   Next

'populate controls
   For I = 1 To 6
       Me("lblDate" & I) = Nz(DLookup("Event", "tblDaysFrom", "ID = " & I), "")
       Me("txtDate" & I) = Nz(DLookup("StartDate", "tblDaysFrom", "ID = " & I), "")

       dteDate = Nz(DLookup("StartDate", "tblDaysFrom", "ID = " & I), Date)
       Me("lblDays" & I).Caption = Nz(DateDiff("d", dteDate, Date), 0)

       If Me("lblDays" & I).Caption > 0 Then Me("lblDays" & I).Visible = True
   Next

   For I = 7 To 12
       Me("lblDate" & I) = Nz(DLookup("Event", "tblDaysTo", "ID = " & (I - 6)), "")
       Me("txtDate" & I) = Nz(DLookup("EndDate", "tblDaysTo", "ID = " & (I - 6)), "")

       dteDate = Nz(DLookup("EndDate", "tblDaysTo", "ID = " & (I - 6)), Date)
       Me("lblDays" & I).Caption = Nz(DateDiff("d", Date, dteDate), 0)

       If Me("lblDays" & I).Caption > 0 Then Me("lblDays" & I).Visible = True
   Next

End Sub



Click to download:  Day Tracker (zipped)



Colin Riddington             Mendip Data Systems            Last Updated 25 Jun 2017

Return to Code Samples Page Return to Top