Good point on auto number. I have a VBA incremented number with 2 fields that will increment under certain conditions.
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Error
If IsNull(Me.Change_Requested) And IsNull(Me.Rationale) Then
Me.Next.Enabled = False
Me.Undo
Cancel = True
Else
Me.Next.Enabled = True
Error_Handler_Exit:
Exit Sub
Error:
Select Case Err.Number
Case 2501
Err.Clear
Resume Error_Handler_Exit
Case Else
MsgBox "Error No. " & Err.Number & vbCrLf & "Description: " & Err.Description, vbExclamation, "Database Error"
Err.Clear
Resume Error_Handler_Exit
End Select
Exit Sub
End If
End Sub
Private Sub Form_Current()
Me.O6Vote.Enabled = False
Me.GOVote.Enabled = False
Me.FinalVote.Enabled = False
Me.Soft_Level.Visible = (Me.Level = "Software")
Dim tmpNIE As Double
tmpNIE = DLookup("NIE", "Change Request")
Me.NIE = tmpNIE
If IsNull(CR_No) And DLast("Action_Complete", "[Change Request]") = True Then
Me.CR_Num = DMax("CR_No", "[Change Request]") + 1
Me.Sub_Num = 0
Else
If IsNull(CR_No) And DLast("Action_Complete", "[Change Request]") = False Then
Me.CR_Num = DMax("CR_No", "[Change Request]")
Me.Sub_Num = DLast("Sub_No", "[Change Request]") + 1
End If
End If
End Sub
I know I'm not as eloquent as others, but thus seems to work well for me. so far. With your code added I get a fail "You can't go to the specified record" when I select the next button - which is good. When I select any other button (Except "Close" - Fail to save error continue") I receive the same error as when I select Next. Once accepted I can select the other buttons (for Record navigation) and it will work. I didn't see the error code, but I would like to make an excepts code for everything but the close and next button.