PC Review


Reply
Thread Tools Rate Thread

Requesting Parameter Value on Update Query

 
 
=?Utf-8?B?UEpGcnk=?=
Guest
Posts: n/a
 
      2nd Aug 2007
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.

Private Sub txtCompanyScreened_AfterUpdate()

Dim NewVal As String

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

 
Reply With Quote
 
 
 
 
Baz
Guest
Posts: n/a
 
      2nd Aug 2007
You haven't quoted NewVal properly, thus:

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

"PJFry" <(E-Mail Removed)> wrote in message
news:C3291AF4-703B-4D0D-915E-(E-Mail Removed)...
> 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.
>
> Private Sub txtCompanyScreened_AfterUpdate()
>
> Dim NewVal As String
>
> 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
>



 
Reply With Quote
 
=?Utf-8?B?UEpGcnk=?=
Guest
Posts: n/a
 
      2nd Aug 2007
That did it! Thanks!

"Baz" wrote:

> You haven't quoted NewVal properly, thus:
>
> strSQL = "UPDATE tAuditLogTxt SET txtNewVal=""" & NewVal & _
> """ WHERE anID=(SELECT Max(anID) FROM tAuditLogTxt WHERE txtNTName='" &
> fOSUserName() & "')"
>
> "PJFry" <(E-Mail Removed)> wrote in message
> news:C3291AF4-703B-4D0D-915E-(E-Mail Removed)...
> > 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.
> >
> > Private Sub txtCompanyScreened_AfterUpdate()
> >
> > Dim NewVal As String
> >
> > 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
> >

>
>
>

 
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
Union Query requesting parameter Tige Brown Microsoft Access Queries 12 25th Feb 2009 04:37 AM
Query requesting parameter value twice tbrogdon@gmail.com Microsoft Access Form Coding 7 20th Dec 2007 11:08 PM
Combining an update query with a parameter query jenster84 Microsoft Access Queries 1 20th Oct 2007 05:33 AM
Re: Form Requesting a non-existing parameter Rob Parker Microsoft Access Form Coding 0 12th Dec 2006 12:01 AM
UPDATE query asking for parameter Lisa Microsoft Access Queries 3 18th Feb 2004 11:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:09 PM.