View Full Version : how can I stop a record being changed after it is changed to a certain value


DazHAT
05-16-2007, 09:41 AM
how can I stop a record being changed after it is changed to a cirtain value?

my senario is this:

a shop has an order table one of the fields is status.

the status can be [order recived] or [awaiting delivery].

I have code that updates the amount in stock when the field is changed to order recived.

how do I stop the user repeatedly changing the field to order recived by mistake (and therby increasing the nuber in stock)? Is ther an easy way to do this in the Private Sub Status_Change()
???

Alc
05-16-2007, 09:51 AM
You could add code to the 'Before Update' event that looks to see what the original status is and refuses any updates if it's already set to Order Received.

DazHAT
05-16-2007, 10:06 AM
I have tried it but it will run the code nomatter which option the status fiekld is set to.

If [status] = "order recived" then
etc etc

but it runs even if the status is set back to awaiting delivery

Alc
05-16-2007, 10:32 AM
What code do you have behind the BeforeUpdate event of the field in question?

DazHAT
05-16-2007, 10:51 AM
If [status] = "order recived" then
msgbox("error")
exit sub
else
end if

end sub

rainman89
05-16-2007, 10:51 AM
you need a cancel=true in there after the message box