PC Review


Reply
Thread Tools Rate Thread

Incorrect values written during an update

 
 
=?Utf-8?B?UEpGcnk=?=
Guest
Posts: n/a
 
      1st Aug 2007
I have an after udpate event that is supposed to write the updated value to
an audit log. The code does update the correct record, but it updates it to
a time field. For example, the updated record should read 8/1/2007, instead
it reads 12/30/1899. If I select that field, the value shows as 12:05:44 AM.

Here is the code:
Private Sub dtmCCSContractSigned_AfterUpdate()

Dim NewVal As Date

NewVal = Me.dtmCCSContractSigned

strSQL = "UPDATE tAuditLogDt SET dtmNewVal= " & NewVal & _
" WHERE anID=(SELECT Max(anID) FROM tAuditLogDt WHERE txtNTName='" &
fOSUserName() & "')"

DoCmd.RunSQL strSQL
End Sub

Any thoughts?

PJ
 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      1st Aug 2007
Date/time values need to be delimited with # characters (and need to be in a
format Access will recognize, since it doesn't respect regional settings).

Try:

Private Sub dtmCCSContractSigned_AfterUpdate()

Dim NewVal As Date

NewVal = Me.dtmCCSContractSigned

strSQL = "UPDATE tAuditLogDt SET dtmNewVal= " & _
Format(NewVal, "\#yyyy\-mm\-dd hh\:nn\:ss\#) & _
" WHERE anID=(SELECT Max(anID) FROM tAuditLogDt WHERE txtNTName='" &
fOSUserName() & "')"

DoCmd.RunSQL strSQL
End Sub


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"PJFry" <(E-Mail Removed)> wrote in message
news:5C025F7D-F2E8-45FB-B12D-(E-Mail Removed)...
>I have an after udpate event that is supposed to write the updated value to
> an audit log. The code does update the correct record, but it updates it
> to
> a time field. For example, the updated record should read 8/1/2007,
> instead
> it reads 12/30/1899. If I select that field, the value shows as 12:05:44
> AM.
>
> Here is the code:
> Private Sub dtmCCSContractSigned_AfterUpdate()
>
> Dim NewVal As Date
>
> NewVal = Me.dtmCCSContractSigned
>
> strSQL = "UPDATE tAuditLogDt SET dtmNewVal= " & NewVal & _
> " WHERE anID=(SELECT Max(anID) FROM tAuditLogDt WHERE txtNTName='" &
> fOSUserName() & "')"
>
> DoCmd.RunSQL strSQL
> End Sub
>
> Any thoughts?
>
> PJ



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Values from multiselect listbox being written to a table =?Utf-8?B?Sm9hbm5l?= Microsoft Access Form Coding 3 10th Aug 2006 12:00 AM
Written values jam Microsoft Excel Worksheet Functions 1 31st Jul 2006 01:53 PM
Is there a macro or function to convert values to it written text =?Utf-8?B?RGFuZyBUcmFu?= Microsoft Excel Worksheet Functions 1 20th Apr 2006 12:17 AM
Arrays to return a written text and numerical values Toby Microsoft Excel Worksheet Functions 1 17th Mar 2004 05:04 PM
Over written a File that had Correct data with incorrect data raja_turbine Microsoft Excel Misc 2 20th Jan 2004 08:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:35 PM.