CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Before Update Event Problem

Print topic Send  topic

Author Message
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

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.