Brandy
|
| Posted: 05/01/2003, 11:18 AM |
|
I am creating a custodial request database. I have this code below to insert a completed date when the status has changed to "closed".
I put it in as a before update event. II only want a completed date to be inserted if the status is "closed", but it will put the complete date in even if i make no changes and just hit submit. Is there something that needs to be added or changed?
Dim x : x = 3
Dim vResult
vResult = x 'custreq.status_id.value
'//check for mode
If custreq.editmode then
'//record is being updated
If vResult = 3 then custreq.finishdate.value = FormatDateTime(now(), vbGeneralDate)
Else
'//record is being added
'//do nothing.
End If
If this is not enough info please let me know.
Any help will be greatly appreciated.
|
|
|
 |
Hamilton
|
| Posted: 05/01/2003, 12:26 PM |
|
Brandy,
You're going to need to test to see if a value in one of the fields is different from one of the fields in the original recordset.
If any of the fields is different you will set a boolean flag (blnUserChangedRecord) to TRUE.
Then only if the flag is true, will the code execute
Dim SQL
Dim RecordSet
Dim blnUserChangedRecord : blnUserChangedRecord = False
Dim UserId
Dim UserName
Dim WorkPhone
SQL = "SELECT * FROM TABLENAME WHERE"
' Open the recordser
Set RecordSet = DBConnection1.Execute(SQL)
If DBConnection1.Errors.Count = 0 Then
If NOT RecordSet.EOF then
If recordsetName.UserName.field <> CCGetValue(RecordSet, "emp_name") then blnUserChangedRecord = True
If recordsetName.WorkPhone.value <> CCGetValue(RecordSet, "phone_work") Then blnUserChangedRecord = True
End if
' Close the recordser
RecordSet.Close
Set RecordSet = Nothing
Else
Print "SQL Execution Failed."
DBConnection1.Errors.Clear
End If
If custreq.editmode then
'//record is being updated
If vResult = 3 and blnUserChangedRecord = True then
custreq.finishdate.value = FormatDateTime(now(), vbGeneralDate)
Else
'//record is being added
'//do nothing.
End If
|
|
|
 |
|