View Single Post
Old Feb 11th, 2005, 9:06 PM   #10
kbkhoo5053
Newbie
 
Join Date: Feb 2005
Posts: 8
Rep Power: 0 kbkhoo5053 is on a distinguished road
Enquiry About Project

Rory, below are the latest coding tht modify. Does this coding correct? Can u check for me? Can it work? Anything else that need to add?

Private Sub cmdDelete_Click()
datCheckin.DatabaseName = App.Path & "\db.mdb"
sSql = "select * from checkin"
datCheckin.RecordSource = sSql
datCheckin.Refresh

datCheckout.DatabaseName = App.Path & "\db.mdb"
sSql1 = "select * from checkout"
datCheckout.RecordSource = sSql1
datCheckout.Refresh

datRoom.DatabaseName = App.Path & "\db.mdb"
sSql2 = "select * from room"
datRoom.RecordSource = sSql2
datRoom.Refresh

datDaily.DatabaseName = App.Path & "\db.mdb"
sSql3 = "select * from daily"
datDaily.RecordSource = sSql3
datDaily.Refresh

End Sub

Public Function CanRecordBeDeleted(ByVal strRecordDate As String) As Boolean
' Inputs: A string date
' Outputs: True or false
' True: Date occurs in last month or prior
' False: Date occurs this month or later
'
Dim datRecordDate As Date
' Used to hold the date in "VB" form
Dim datStartOfMonth As Date
' Date rolled back to the start of the month
Dim TodayStartOfMonth As Date
' Today rolled back to the start of the month

datRecordDate = CDate(strRecordDate)

datStartOfMonth = VBA.DatePart("m", datRecordDate)
TodayStartOfMonth = VBA.DatePart("m", VBA.Now())
' This built in VB function rounds down to the start of the month

If datStartOfMonth < TodayStartOfMonth Then
CanRecordBeDeleted = True
Else
CanRecordBeDeleted = False
End If

MsgBox("Do you really want to clear all the shift records ?", vbExclamation + vbYesNo, "DELETE ALERT") = vbYes

End Function

Last edited by kbkhoo5053; Feb 11th, 2005 at 9:29 PM.
kbkhoo5053 is offline   Reply With Quote