Call Stored Append Query

M

mickie

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????
 
X

XPS350

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
 
B

Bob Barrows

mickie said:
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 ...
 
M

mickie

mickie said:
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")

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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top