Prev: Help getting Sample database for Doug Den Hoed's article 'Taming the Treeview Control'
Next: scanning to access table
From: RipperT on 14 Sep 2007 04:57 ------------Begin code--------------------------------- Dim rs As DAO.Recordset Set rs = Me.RecordsetClone Dim strInmateID As String strInmateID = Me.ImateID rs.FindFirst "InmateId = '" & strInmateID & "'" If rs.NoMatch Then MsgBox "No entry found.", vbInformation, "Data Not Found" ElseIf Not rs.EOF Then Me.Bookmark = rs.Bookmark End If ------------------End code----------------------------- The line Me.Bookmark = rs.Bookmark generates the following error: "Run-time error '2115': The macro of function set to the BeforeUpdate or ValidationRule property for this field is preventing Access from saving the data in the field." I've removed the BeforeUpdate event code and no change. I've removed the validation rule and no change. What data is Access trying to save? It's just a simple fine record operation. I don't get it. I have nearly the exact same code in another form and it works wonderfully. What could be wrong? Many thanks, Ripper
From: Allen Browne on 14 Sep 2007 05:05
What's wrong is that the current record is dirty (unsaved edits) and cannot be saved. Access must save the current record before it can move to another. If the current record cannot be saved, the attempt to set the form's bookmark to another record will fail. You can verify this is the problem by explicitly saving first: If Me.Dirty Then Me.Dirty = False Include error handling to cope with the case where the record cannot be saved. -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "RipperT" <rippert(a)nOsPaM.net> wrote in message news:umvi70q9HHA.1208(a)TK2MSFTNGP03.phx.gbl... > ------------Begin code--------------------------------- > Dim rs As DAO.Recordset > Set rs = Me.RecordsetClone > Dim strInmateID As String > strInmateID = Me.ImateID > > rs.FindFirst "InmateId = '" & strInmateID & "'" > > If rs.NoMatch Then > MsgBox "No entry found.", vbInformation, "Data Not Found" > ElseIf Not rs.EOF Then > Me.Bookmark = rs.Bookmark > End If > ------------------End code----------------------------- > > The line Me.Bookmark = rs.Bookmark generates the following error: > > "Run-time error '2115': > The macro of function set to the BeforeUpdate or ValidationRule > property for this field is preventing Access from saving the data in the > field." > > I've removed the BeforeUpdate event code and no change. I've removed the > validation rule and no change. > What data is Access trying to save? It's just a simple fine record > operation. I don't get it. > I have nearly the exact same code in another form and it works > wonderfully. What could be wrong? > Many thanks, > > Ripper > |