PC Review


Reply
Thread Tools Rate Thread

Call Stored Append Query

 
 
mickie
Guest
Posts: n/a
 
      1st Jan 2011
I have a stored Append Query that I want to call as part of an 'If
Statement'. The If Statement is assigned to an "AfterUpdate" property
on a form.

The query is called 'qryAppendCCLogTable' and it does work when ran in
application. The SQL is;

INSERT INTO [CC Log] ( [Prop Reference], [Summary of Change] )
SELECT [Proposed Change].[Prop Reference], [Proposed Change].[Summary
of Change]
FROM [Proposed Change]
WHERE ((([Proposed Change].[Accepted As RFC])="yes"));


This is the code I have so far

- - - - - - -
Private Sub Accepted_As_RFC_AfterUpdate()

If Accepted_As_RFC.Value = "Yes" Then

MsgBox ("You are about to add this record to the Change Control
Log")

End

'This is where I want to run the query

Else
'do nothing

End

End If

End Sub
- - - - - - - -
I have tried numerous versions of code from various sources and after
two weeks am starting to want to give up!

Can anyone help pleeeease????


 
Reply With Quote
 
 
 
 
XPS350
Guest
Posts: n/a
 
      2nd Jan 2011
On 2 jan, 00:29, mickie <mickie200...@yahoo.co.uk> wrote:
> I have a stored Append Query that I want to call as part of an 'If
> Statement'. The If Statement is assigned to an "AfterUpdate" property
> on a form.
>
> The query is called 'qryAppendCCLogTable' and it does work when ran in
> application. The SQL is;
>
> INSERT INTO [CC Log] ( [Prop Reference], [Summary of Change] )
> SELECT [Proposed Change].[Prop Reference], [Proposed Change].[Summary
> of Change]
> FROM [Proposed Change]
> WHERE ((([Proposed Change].[Accepted As RFC])="yes"));
>
> This is the code I have so far
>
> - - - - - - -
> Private Sub Accepted_As_RFC_AfterUpdate()
>
> * * If Accepted_As_RFC.Value = "Yes" Then
>
> * * MsgBox ("You are about to add this record to the Change Control
> Log")
>
> * * End
>
> * * 'This is where I want to run the query
>
> * * Else
> * * 'do nothing
>
> * * End
>
> * * End If
>
> End Sub
> - - - - - - - -
> I have tried numerous versions of code from various sources and after
> two weeks am starting to want to give up!
>
> Can anyone help pleeeease????



Did you try: DoCmd.OpenQuery 'qryAppendCCLogTable' ?


Groeten,

Peter
http://access.xps350.com
 
Reply With Quote
 
Bob Barrows
Guest
Posts: n/a
 
      2nd Jan 2011
mickie wrote:
> I have a stored Append Query that I want to call as part of an 'If
> Statement'. The If Statement is assigned to an "AfterUpdate" property
> on a form.
>
> The query is called 'qryAppendCCLogTable' and it does work when ran in
> application. The SQL is;
>
> INSERT INTO [CC Log] ( [Prop Reference], [Summary of Change] )
> SELECT [Proposed Change].[Prop Reference], [Proposed Change].[Summary
> of Change]
> FROM [Proposed Change]
> WHERE ((([Proposed Change].[Accepted As RFC])="yes"));
>
>
> This is the code I have so far
>
> - - - - - - -
> Private Sub Accepted_As_RFC_AfterUpdate()
>
> If Accepted_As_RFC.Value = "Yes" Then
>
> MsgBox ("You are about to add this record to the Change Control
> Log")
>
> End

?? What's the "End" for?
>
> 'This is where I want to run the query
>
> Else
> 'do nothing
>
> End

Again - why is the "End" here?
PS. The "Else" branch is optional - if you wish to do nothing, then simply
omit the "Else"
>
> End If
>
> End Sub
> - - - - - - - -
> I have tried numerous versions of code from various sources and after
> two weeks am starting to want to give up!
>
> Can anyone help pleeeease????


I'm not sure what the problem is. Is it that you don't know how to execute
the query? If so, try:
CurrentDB.Querydefs("qryAppendCCLogTable").Execute dbFailOnError

Or is the problem that an error occurs when you execute the query in code?
If so, we're not mindreaders - you need to tell us about the error ...


 
Reply With Quote
 
mickie
Guest
Posts: n/a
 
      4th Jan 2011
On Jan 2, 10:30*am, "Bob Barrows" <reb01...@NOSPAMyahoo.com> wrote:
> mickie wrote:
> > I have a stored Append Query that I want to call as part of an 'If
> > Statement'. The If Statement is assigned to an "AfterUpdate" property
> > on a form.

>
> > The query is called 'qryAppendCCLogTable' and it does work when ran in
> > application. The SQL is;

>
> > INSERT INTO [CC Log] ( [Prop Reference], [Summary of Change] )
> > SELECT [Proposed Change].[Prop Reference], [Proposed Change].[Summary
> > of Change]
> > FROM [Proposed Change]
> > WHERE ((([Proposed Change].[Accepted As RFC])="yes"));

>
> > This is the code I have so far

>
> > - - - - - - -
> > Private Sub Accepted_As_RFC_AfterUpdate()

>
> > * *If Accepted_As_RFC.Value = "Yes" Then

>
> > * *MsgBox ("You are about to add this record to the Change Control
> > Log")

>
> > * *End

>
> ?? What's the "End" for?
>
> > * *'This is where I want to run the query

>
> > * *Else
> > * *'do nothing

>
> > * *End

>
> Again - why is the "End" here?
> PS. The "Else" branch is optional - if you wish to do nothing, then simply
> omit the "Else"
>
>
>
> > * *End If

>
> > End Sub
> > - - - - - - - -
> > I have tried numerous versions of code from various sources and after
> > two weeks am starting to want to give up!

>
> > Can anyone help pleeeease????

>
> I'm not sure what the problem is. Is it that you don't know how to execute
> the query? If so, try:
> CurrentDB.Querydefs("qryAppendCCLogTable").Execute dbFailOnError
>
> Or is the problem that an error occurs when you execute the query in code?
> If so, we're not mindreaders - you need to tell us about the error ...- Hide quoted text -
>
> - Show quoted text -


Hi Bob

Thanks for the response.

I had tried a couple of DoCmd actions and even tried running an sql
string. None of them worked.

Saw your reply asking why the 'End' and thought good question!"
Removed the 'End' and it worked.

Thanks

mickie

 
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
Append query to append lots of record with range input domibud Microsoft Access Queries 7 9th May 2008 02:26 AM
Append Query in VBA - to append VBA variable values to Access tabl =?Utf-8?B?QWdlbnQgRGFnbmFtaXQ=?= Microsoft Access VBA Modules 4 1st Nov 2006 04:25 PM
Link CSV file created query append query to append data =?Utf-8?B?ZXNwYXJ6YW9uZQ==?= Microsoft Access Queries 2 5th Jul 2005 04:49 PM
Re: Stored Procedure call failed in VB.NET, OK in Query Analyzer Net Microsoft ADO .NET 0 10th Aug 2003 07:20 AM
Re: Stored Procedure call failed in VB.NET, OK in Query Analyzer Bob Johnson Microsoft ADO .NET 0 8th Aug 2003 02:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:08 PM.