Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parameter value on update query 1

Status
Not open for further replies.

PJFry

Technical User
Feb 6, 2005
93
US
I have an audit log that records the values of a control before and after it
is changed. The first part of the process runs on an OnDirty event to record
the value before the change and the second part runs on an AfterUpdate event
(code below).

The OnDirty part works fine, but when I try to execute the code below, I am
prompted for a parameter value. There is identical code that runs on 15
other controls with no problem. The other updates are on dates and numbers.

One interesting thing to note is that if I enter a numeric charater instead
of a text character, the code runs fine.

Code:
Private Sub txtCompanyScreened_AfterUpdate()

Dim NewVal As String

[COLOR=green]'Set NewVal to be the new control value[/color]
NewVal = Me.txtCompanyScreened

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

DoCmd.RunSQL strSQL

End Sub
I am running 2003 on XP.

Thoughts?

PJ

 
Perhaps this ?
Code:
strSQL = "UPDATE tAuditLogTxt SET txtNewVal=[!]'[/!]" & NewVal [!]& "'"[/!] & _

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Perfect! That did the trick.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top