I cannot get the results of an update query to appear on my Access form

I have a form that is actually a main form, a tabbed form, a subform on a tab, and a subform within that tab.  The subform pulls from its own table and is populated by selecting one option from a provided dropdown box.  I attached a macro to choose whether a new record needs to be added using the dropdown selection or whether an existing one needs to be updated.  

Once the update has been made to the record, I'm trying to reflect the change on the form.  I keep getting a conflict message.  I've attached a copy of the subform and the error message.  help.

  the subformthe error
jwandmrsquaredAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PatHartmanCommented:
You are conflicting with yourself.  The form is bound and something made it "dirty" so Access knows the current record needs to be saved.  You then ran a macro to update the bound record.

It is never a good idea to use an update query to update the record you are looking at.

You can start by figuring out what is dirtying the current record.  Is your combo bound?  If so, that would do it.  You should not be using a bound combo to enter selection criteria.  If you can keep the current record from becoming dirty before you run the update, you may be able to prevent the scary message or it may just move to the point in time where you try to save the current record using the form.

I don't have a clear picture of what you are trying to do so I can't be too specific. Usually an "add new" button just moves the current record to a "new" record.  It sounds like you are having the user enter some value BEFORE you move to the "new" record and that could be the issue.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jwandmrsquaredAuthor Commented:
I ended up converting the macro to vba, then inserting a requery statement. I've tested numerous times and it seems to be working.  I am keeping your notes above about not updating the record you are on, I didn't know that.
0
jwandmrsquaredAuthor Commented:
Guided me in the right direction.
0
PatHartmanCommented:
The requery is forcing the current record to be saved and so since it is no longer dirty, the message went away.  This gets you past the error message but I suggest that you rethink the entire process in light of my earlier comments.  

I'm going to add another "never".  Never rely on the byproduct of a statement.  If you want to save the record, save it using the correct VBA command - DoCmd.RunCommand acCmdSaveRecord OR in some cases you might need to use
If Me.Dirty Then
    Me.Dirty = False           '''force save record
End If

If you ever have to use the Me.Dirty trick (and it is a trick since it obfuscates the actual action), always comment it because the obvious interpretation of the statement is that you are cancelling the update by resetting the dirty flag rather than forcing the update.

Both requery and refresh as a side effect, save the current record but they have awkward side effects that you don't get if you simply save the current record.  I'm telling you this because you didn't know that the Requery was forcing the record to be saved and that was why the message went away and someday, you might run into trouble because you used Requery rather than the correct save instruction.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.