access - update form only with button control -
i saw answeres here none of them fitted me.
i have form bounded inputs, want user able edit. though, when user changes fields, , close form - without clicking "update" button - changes data in database.
is there way verify data changed when "update" button pressed?
thanks
you following:
1) define global variable in form "buttonpressed" , set false when enter form or record (e.g. oncurrent).
2) in form_beforeupdate() put following code:
if not buttonpressed cancel = true
3) in button_click() put following code:
buttonpressed = true docmd.runcommand accmdsaverecord
4) reset buttonpressed after updating form in form_afterupdate() whole code should this:
option compare database option explicit dim buttonpressed boolean private sub button_click() buttonpressed = true docmd.runcommand accmdsaverecord end sub private sub form_afterupdate() buttonpressed = false end sub private sub form_beforeupdate(cancel integer) if not buttonpressed cancel = true end sub private sub form_current() buttonpressed = false end sub private sub form_unload(cancel integer) me.undo end sub private sub form_error(dataerr integer, response integer) if dataerr = 2169 response = true end if end sub
Comments
Post a Comment