Go Back   Access World Forums > Microsoft Access Discussion > Queries

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 09-21-2019, 08:19 PM   #1
T. McConnell
Newly Registered User
 
Join Date: Jun 2019
Posts: 38
Thanks: 12
Thanked 0 Times in 0 Posts
T. McConnell is on a distinguished road
Have to run an append query twice??

Hey all,
I am having an issue I have an append query that is to add new records to a table. The query is tied to a button that checks to see if a checkbox is checked and if so to run the append query. The problem is when I check the box and then click my Save button nothing is copied over, but if I go back into the record and re-save it again the data shows up. I have tried the below code but it only seems to work if I do it twice. The commented section out are the other ways I tried to run the query but same result each time. Any suggestions would be greatly appreciated.

MoveToInventory is the checkbox name and of course QryExpenseToInventory is my query which copies over certain fields to the OtherInventory table.

Code:
Private Sub btnSave_Click()
If Me.MoveToInventory.Value = True Then
'CurrentDb.Execute "QryExpenseToInventory"
'DoCmd.OpenQuery "QryExpenseToInventory", acNormal, acEdit
DoCmd.SetWarnings False
DoCmd.OpenQuery "QryExpenseToInventory"
DoCmd.SetWarnings True
End If
End Sub
I have another query similar to this one based on the same button and both do the same, nothing shows up unless I run the save button again.

Thanks!

T. McConnell is offline   Reply With Quote
Old 09-21-2019, 08:27 PM   #2
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 33,399
Thanks: 13
Thanked 4,125 Times in 4,057 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Have to run an append query twice??

Perhaps the record needs to be saved first?

If Me.Dirty Then Me.Dirty = False
__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
The Following User Says Thank You to pbaldy For This Useful Post:
T. McConnell (09-21-2019)
Old 09-21-2019, 08:38 PM   #3
T. McConnell
Newly Registered User
 
Join Date: Jun 2019
Posts: 38
Thanks: 12
Thanked 0 Times in 0 Posts
T. McConnell is on a distinguished road
Re: Have to run an append query twice??

PBaldy,
Thank you again for your help. I don't know why I can't remember that bit of code.
You helped greatly!

T. McConnell is offline   Reply With Quote
Old 09-21-2019, 09:07 PM   #4
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 33,399
Thanks: 13
Thanked 4,125 Times in 4,057 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Have to run an append query twice??

Happy to help!

__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop and Append Query until the Append query no longer produces results. Speiro1 Modules & VBA 3 05-02-2017 12:27 PM
Need to ignore Microsoft Access can't append all the records in the append query DNASok Queries 7 03-21-2013 06:22 AM
Append Query that can append to multiple tables JuniorWoodchuck24 Queries 3 05-25-2011 12:56 AM
Append Query - Append Field keeps changing LB79 Queries 1 07-03-2009 02:09 AM
MS access can't append all the records in the append query japi_s General 3 02-19-2007 06:09 AM




All times are GMT -8. The time now is 11:25 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World