like I said, i use the same code in a differet (older app) as I am trying to do this one better, and it will undo a record with no issues.
Often claimed to be the same, seldom true. If it were true it should work?
Not sure what else to tell you at this point. I step through and sometimes the UniqueID function is called sometimes not. No idea at the moment as to what's calling it, but when it runs it seems to add a record to tblAccount even though tblUniqueIDs has no relationships set. I cannot do a table refresh from the ribbon until the function is finished, but when I do, there's a new record even though there should not be. When it doesn't run, there's no record until you get to here in the current event
Code:
If IsActive = True Then
Me.AccountClosed = Null
Me.RecordLock = False
Else
Me.AccountClosed = Now()
Me.RecordLock = True
End If
Me.Dirty = False
Me.Refresh
End Sub
That makes sense to me, the function thing doesn't. How did you copy this file for posting? If from Windows Explorer, I suspect you might have copied a db that needs to be decompiled. I'm going to do that and see what happens about the function call. However, the red Me. lines make the form dirty and the bold saves the record as I said, so I cannot see how you can not save a record regardless, and then there is no Undo-ing. I can see that by refreshing the table as I step through.
Other observations:
When the function ran TxtRecordNo showed 46 of 45
Select Case Me.cboAccountTypeID < Current event, case is 0 for new record. No block for that? Should have Case Else to notify you of the unexpected.
Select Case Me.cboAccountTypeID < don't need IF block that follows, just the Me. lines. The Case statement is sort of an IF in itself.
You could probably cut out a lot of your code. If a control is invisible, I don't think you have to worry about making it enabled since it can't take focus.
EDIT - consider testing for both Me.NewRecord AND Me.Dirty then make False or not, as appropriate. Or don't make it False at any time. Is this necessary?
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.