By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,475 Members | 1,372 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,475 IT Pros & Developers. It's quick & easy.

The data has been changed

reginaldmerritt
100+
P: 201
This seems to be a common issue, I've read all the solutions to this I could find and I can't see where I'm still going wrong.

I have two forms, one is a continuous list of records the other is a single record showing further details.

From the single record form I save the record, then run a public subroutine which loops though all of the records and updates them, I then run a requery on both forms.

Expand|Select|Wrap|Line Numbers
  1. Private Sub ExamVenueID_AfterUpdate()
  2.  
  3. If Me.Dirty Then Me.Dirty = False
  4.  
  5. UpdateExamVenueHireStatus
  6. Me.ExamVenueHireStatusID.Requery
  7. Forms.FRMExamVenueHire.Requery
  8.  
  9. End Sub
  10.  
I won't put up the content of the public subroutine which uses record sets to update all the records just yet; as this subroutine is a little complex.

The first time I run through ExamVenueID_AfterUpdate above, everything works fine, the second time I get the "The data has been changed" error.

I have saved the record, I don't understand what else I should do, any suggestions ?
Aug 16 '12 #1

✓ answered by TheSmileyCoder

Then you need to first determine which event causes the error to fire.

You say it works the first time (without error) but gives an error the second time around. My guess would be that your UpdateExamVenueHireStatus causes the active record to be changed as well.

Try adding a Me.Refresh to the end of the code shown in your first post, and lets us know if that solves anything.

Share this Question
Share on Google+
6 Replies


twinnyfo
Expert Mod 2.5K+
P: 3,045
Reginald,

Have you tried stepping through each line of code as it executes on the form? Also, do you have anything running on the OnCurrent Event of either form? If there are any changes that occur in this event, it may be changing some of your data.

I have had a few issues similar to your in the past, and it simply took going line by line to see what values are changing and when they are changing.

This may not offer a "solution" but offers a method of troubleshooting. There may also be some bigger brains on this forum who could ID the problem right away, but without the DB in hand (or the code) it's difficult to pinpoint such an error.
Aug 16 '12 #2

reginaldmerritt
100+
P: 201
Fair enough twinnyfo, thank you for your post.

I don't have anything running OnCurrent but when i use a line toggle break on the 'if me.dirty then me.dirty = false' the error appears before it gets to that point. In other words the ExamVenueID_AfterUpdate event doesn't even get to happen, therefore i have been unable to go though each line as Access kicks me out before its even begun.
Aug 16 '12 #3

TheSmileyCoder
Expert Mod 100+
P: 2,321
Then you need to first determine which event causes the error to fire.

You say it works the first time (without error) but gives an error the second time around. My guess would be that your UpdateExamVenueHireStatus causes the active record to be changed as well.

Try adding a Me.Refresh to the end of the code shown in your first post, and lets us know if that solves anything.
Aug 16 '12 #4

reginaldmerritt
100+
P: 201
Hi Smileycode, thanks for your post. Yes your right the problem is with changing an active record but I thought by using "me.dirty" and ".refresh" that I would have covered everything.

I was trying to refresh just the field that was changed "Me.ExamVenueHireStatusID.Requery" via the record set used in UpdateExamVenueHireStatus, I tried "me.refresh" instead but that didn't help, but I see where your coming from.

UpdateExamVenueHireStatus was on a separate module from any form, not because it had to be, just because I thought maybe in the future I might need to run it from another form. It also used a recordset to loop though all the records, but again this wasn't really necessary. Trying to be to cleaver I think.

I moved UpdateExamVenueHireStatus back into the forms code and rather than using a record set to loop though all the records it now just use "me." to change the record being viewed.

This has now gotten rid of the 'The data has been changed' error.Bit of of a cop out I know, and I'm sure I'll come across this problem again in the future so perhaps I'll revisit this some time.
Aug 17 '12 #5

zmbd
Expert Mod 5K+
P: 5,287
Try the Me.Requery as it appears that the underlying query has changed. The dirty=false saved the record; however it doesn't always make that known... weird little quirk in access especially with split databases.

I've ran into something very similar.
When the database was all in one... the code worked just fine; however, once split I ran into just that message...
I initially tried the "refresh" thingy - no joy.
I then ran across this:http://allenbrowne.com/bug-01.html when led me to http://office.microsoft.com/en-us/ac...005187598.aspx so I then changed to a full requery within the forms code and all was well.

-z
Aug 17 '12 #6

TheSmileyCoder
Expert Mod 100+
P: 2,321
Glad to hear you got it working. Whether or not the code is within the module should not in itself affect the result. However opening a secondary recordset (the primary being the recordset bound to the form) this behaviour would certainly occur. Now I don't know exactly what you are doing, but in general I would never try to do anything with a recordset that could be done by simply using the Me.???, so from what you have described I would not call it a cop-out.

Ps. Of course you cannot use Me from a seperate module, but its perfectly possible to pass the current form to a seperate procedure in a module.
Aug 17 '12 #7

Post your reply

Sign in to post your reply or Sign up for a free account.