strBoomark is set in the declaration section of frmPersonnel above so is available through-out this class module.
Private strBookmark as Variant
1. On clicking on Add Record button I am trying to save the bookmark of the current record just prior to adding a new record (Highlighted Blue), so that if I abandon the new record, I can go back to the previous record.
2. After the New Record opens, I then want to offer the user the option of either saving the New Record or Abandoning it in the Form_BeforeUpdate Event below:Private Sub cmbAddNew_Click()If glbHandleErrors Then On Error GoTo ErrHandler ' Set Error Handling Dim dbs As DAO.Database ' Dimension Database Dim rs As DAO.Recordset ' Dimesion Recordset Set dbs = CurrentDb Set rs = Me.RecordsetClone If Forms!frmLoginScreen!numSecurityLevel >= 8 Then ' Checks Security Clearance strBookMark = rs.Bookmark 'Set Bookmark for current record Call addNewRecord("frmPersonnel", "fkTitleID") ' Add New Record Function Me!frmStatusSubForm.Form.AllowAdditions = True ' Set Allow Additions Default Setting. Call modTracking(Me.Name, 1, Environ("ComputerName"), Environ("UserName"), "") ' Tracks Addition of Record to WLP System. End If ExitHere: ' Any Clean Up Code rs.Close dbs.Close Set rs = Nothing Set dbs = Nothing Err.Clear Exit Sub ErrHandler: ' ERROR HANDLING ROUTINE. If Err.Number <> 0 Then Call LogError(Err.Number, Err.Description, Forms!frmLoginScreen!fkID, Environ("UserName"), Environ("ComputerName"), "", glbHandleErrors) Resume ExitHere End If End Sub
3. On abandonment I want to return to the previous record(in Blue), but it's not working because strBookMark = Empty
Can anybody tell me what I'm doing wrong, strBookMark is Empty and it seems that after Cancel = True the form is not pointing at any record in the table.Private Sub Form_BeforeUpdate(Cancel As Integer) If glbHandleErrors Then On Error GoTo ErrHandler ' Set Error Handling Dim dbs As DAO.Database ' Dimension Database Dim rs As DAO.Recordset ' Dimesion Recordset Set dbs = CurrentDb Set rs = Me.RecordsetClone Dim strMessage As String, Response If Me.NewRecord = True Then ' Validates if New Record ' Validate that Surname has Entered is a NEW record. If IsNull(txtSurname) Then ' Initialise Message String. strMessage = "Cannot Save Record Without Surname." & vbCrLf _ & "Select YES to return to Surname Field." & vbCrLf _ & "Select NO to Abandon Change(s). Return to Previous Record." Response = MsgBox(strMessage, vbYesNo) If Response = vbNo Then Cancel = True ' Cancel Record Save/Update rs.Bookmark = strBookMark Me.txtSearch.SetFocus GoTo ExitHere: Else Me.txtSurname.SetFocus GoTo ExitHere: End If End If End If ExitHere: ' Any Clean Up Code rs.Close dbs.Close Set rs = Nothing Set dbs = Nothing Err.Clear Exit Sub ErrHandler: ' ERROR HANDLING ROUTINE. If Err.Number <> 0 Then Call LogError(Err.Number, Err.Description, Forms!frmLoginScreen!fkID, Environ("UserName"), Environ("ComputerName"), "", glbHandleErrors) Resume ExitHere End If End Sub
Been trying for about a week to resolve this issue, can anyone give me an idea of what to do!!





 
			
			 
					
				 
                    
            
                 
            
            
         
					
					
					
						 Reply With Quote
  Reply With Quote 
			