Thursday 15 March 2012

How do I prevent an error 2101 in Access when I have a button to save a record on a form? -


I think there is something like this (and I believe I was working once)

I

Button's onclick handler is basically a

  private sub BTNSA_click (), which is a combination with some bound control and a button The record is. Me.dirty = false end sub  

Since I need to check the values ​​entered, there is still an on-up update handler:

  Private sub form_beforeupdate (cancel as integer)) if nz (me.SomeControl, "") = "" msgbox ("....") cancel = true exit sub end if '... check more .. End end  

Now, when I click on the button, and the handler reaches me.dirty = false, the execution flow goes to the update handler earlier, which is expected She goes. Since the ice-control is not filled, the cancellation has been set to the right and all is finished, which is still expected.

The problem occurs when the execution flow comes back to the button. The line me.dirty = false prevents execution and run-time error '2101' is not valid for the setting you enter this property is filed.

This is not expected and I really believe that I have to do this work.

Anyway, how do I do the first save button together with the predecessor handler?

Do you need to save the record at this point, given that the default for saving access is? If this is the case, then the error will likely be framed:

  Personal sub btnSave_Click () error GoTo Err_Handler at Me.Dirty = False Exit_Here: Exit sub Err_Handler: If Err.Number = 2101 then ' Neglect or message like MSBBX error Descriptration and if you want to resume, exit_array and all  

No comments:

Post a Comment