I assume that you mean the before update event for the textbox?
Data in the table should get altered until the AFTER UPDATE event so I'm a bit puzzled as to why you indicate that it does.
The befor eupdate event can be used to evaluate the entered data and if in case of an error you can set the cancel update to true so that focus stays in that field until it is corrected.
terry, thanks for quick reaction. Yes, it is the BeforeUpdate event for the textbox I am talking about. I agree that it is not during the BeforeUpdate event that the record in the table is updated, but I want to prevent the table from being updated, and for that I use the BeforeUpdate event.
And you confirm my experience, that focus stays in the textbox.
The link you gave shows that if I include "Me.txtOrganisatie.Undo" in the code then I can move the focus, but then the value reverts to the old value.
What I am trying to achieve is (1) The user enters a new value in txtOrganisatie. (2) This new value stays in the textbox for later use, (3) but the record in the table is not updated. (4) Later the record in the table may or may not have to be updated depending on other actions and then after for example an OnClick event on t button.
How am I to achieve this?
If you need to validate a specific field then do it in the controls before update event.
If you need to validate more than one field before commiting the data to the dB then I would do it in the forms before update event. Then set cancel to true if one or more fields are invalid.
You should read that link I gave it contains information as to when changes are commited to the db and you mnay need to take these into account.
I was hoping a quick fix existed. I may have to do some more brainstorming on the whole problem and then come back.
(One of the issues is this: if the adress belonging to a name is changed and there are several persons living on the adres, such as father, mother, and children, then it needs to be checked whether the whole family moves and we need an UPDATE with the new adres replacing the old adress, or it is one of the children that moves out and we need an INSERT with the new adress added. And if a telephone number is changed it needs to be checked whether the person changes telephonenumber or gets one additional one.)
(As for when changes are committed I am presently studying "Access 2007 VBA" by Scott B. Diamond, and he goes into quite some details on these matters (and I read the link you gave me, thanks.))
A rethink and then I come back.
So you sent me in another direction. I am starting slow, just with the name of the organisation. I have in the table an aritifial organisation with the name (New) - it is in brackets so that it will come up first in a list sortet alfatetically. If the user wants to change the name of an existing organisation he choses that name in the form1 which brings up the name in a textbox in form2. A change to that textbox results in an update to the database. If the user wants to add a new organisation he choses (New) which brings up (New) in the textbox. When the user changes (New) to the name of the new organisation I wanted not to update the table, thereby overwriting (New) but to insert the new name. The way I have now solved it is this: Before update I save the textbox's old text to a variable s. Then I let (New) overwrite in the table. Then in the form close event I test whether s = (New) and if so I insert a new organisation with the name (New).
Please create a 'svar' for having my rethink. Maybe you also want to comment on this method?
Christian, give yourself the points I havent been too helpful here.
I think I understand the idea with using (New) but its difficult to comment on it as I dont have enough understanding of your database or requirements.
I read your commone at #5 again and maybe it would be possible to prompt the user if they try altering an address where one or more people live as to whether or not the whole family or only some of them are moving to a new address. Then depeneding on what they answer you can react accordingly.
All family: Update
Some of: Open a from where its possible to choose those who are moving and then insert new address and undo changes to old record.