Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 13th, 2005, 5:46 PM   #11
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
Well it would, if you actually called the second function. Also the second function, as it name implies, doesn't do the deleting it just checks whether the record is more than a month old. You need to write that bit of the code!
Rory is offline   Reply With Quote
Old Feb 13th, 2005, 8:51 PM   #12
kbkhoo5053
Newbie
 
Join Date: Feb 2005
Posts: 8
Rep Power: 0 kbkhoo5053 is on a distinguished road
Enquiry About VB Project

Rory, I am not understand what do u mean by second function? How to write it? Can you guide me? Thanks.
kbkhoo5053 is offline   Reply With Quote
Old Feb 14th, 2005, 1:36 PM   #13
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
Well all that should work if you actually write the code to delete the record! Also I assume you need an if statement around the msgbox(). If you want any more help, you'll have to post a bit more of the source - I'm still not fully clear what you're asking
Rory is offline   Reply With Quote
Old Feb 15th, 2005, 2:20 AM   #14
kbkhoo5053
Newbie
 
Join Date: Feb 2005
Posts: 8
Rep Power: 0 kbkhoo5053 is on a distinguished road
Enquiry About VB Project

Rory, i add in if statement around the msgbox(). Can u help me check whether there is error or not? Can? Thanks. 2molo i need to submit my program to my supervisor. Plz help me ensure the full program below. Thanks you very much.

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

if DateDiff("date", datein, dateout) >=30 then

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

End Function

The code is only getting the months? How about dates such as "1/1/1900"?
How to is include the year in the comparison?

Rory, I test it, no errors. However, I still can't get my answer. It cannot delete the shift report. No changes even thought I insert the coding that u gav me. It still remains same. How? Can u help me?

Last edited by kbkhoo5053; Feb 16th, 2005 at 1:36 AM.
kbkhoo5053 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:51 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC