Have to run an append query twice?? (1 Viewer)

T. McConnell

Registered User.
Local time
Today, 10:46
Joined
Jun 21, 2019
Messages
63
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!
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 07:46
Joined
Aug 30, 2003
Messages
36,118
Perhaps the record needs to be saved first?

If Me.Dirty Then Me.Dirty = False
 

T. McConnell

Registered User.
Local time
Today, 10:46
Joined
Jun 21, 2019
Messages
63
PBaldy,
Thank you again for your help. I don't know why I can't remember that bit of code.
You helped greatly!
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 07:46
Joined
Aug 30, 2003
Messages
36,118
Happy to help!
 

Users who are viewing this thread

Top Bottom