K
Kelii
So, this is probably the simplest form in my database and it
intermitently kicks out an error "No current record." The help screen
is close to worthless, and hours of searching our newsgroup has only
made me more confused.
The error occurs when I close my form. However, the error does not
occur regularly, it only occurs when I navigate from one record to the
next, using my next record command button. This is to say, if I open
my form, then close it ... no error occurs. Furthermore, the error
does not occur consistently on any particular record. For example, if
I simply navigate to the 3rd record, then the form will close with no
error. However, if I navigate to the last record, back to the first
record, then to the third record, the form will close with the error.
Finally, the error is not trapped in any of my error handlers (which I
have dutifully included on every single sub and function). I have
tried trapping the error in a Form_Unload event, however, the error
occurs before this event. Furthermore, I included Debug.Print
Me.CurrentRecord in the Form_Unload event and I'm getting the proper
record printed, even when the No current record error is generated.
My question: does anyone have a sense of where to start debugging this
problem, or in a perfect world how to fix this?
My suspicion is that the error is being driven by the code in my
Form_Load sub, in particular the RecordsetClone and Bookmark pieces,
which admittedly I am hazy on understanding. The code is included
here:
Private Sub Form_Load()
On Error GoTo Error_Handler
'If this form loads with open args, then the item has already been
'entered and the unit of measure data should not be enabled
'Convoluted load procedure allows navigation buttons to work
If Len(Me.OpenArgs) > 0 Then
'Disable the unit of measure fields
With Me.Item_Unit_of_Measure
.Enabled = False
End With
'Go to proper record and allow navigation buttons to work
With Me.RecordsetClone
.FindFirst "Item_Description_ID = '" &
FindFirstFixup(Me.OpenArgs) & "'"
If .NoMatch Then
MsgBox "Item Not Found", vbOKOnly, "Item Lookup"
Else
Me.Bookmark = .Bookmark
End If
End With
End If
'Update subform windows
DateAnalyze
Exit_Procedure:
On Error Resume Next
Exit Sub
Error_Handler:
Select Case Err
Case Else
MsgBox "Error: " & Err.Number & vbCr & Err.Description
Resume Exit_Procedure
End Select
End Sub
The code in my navigation buttons may also be contributing to the
confusion.
Private Sub cmdFirstRecord_Click()
On Error GoTo Error_Handler
DoCmd.GoToRecord , , acFirst
Exit_Procedure:
On Error Resume Next
Exit Sub
Error_Handler:
Select Case Err
Case Else
MsgBox "Error: " & Err.Number & vbCr & Err.Description
Resume Exit_Procedure
End Select
End Sub
Private Sub cmdPreviousRecord_Click()
On Error GoTo Error_Handler
DoCmd.GoToRecord , , acPrevious
Exit_Procedure:
On Error Resume Next
Exit Sub
Error_Handler:
Select Case Err
Case Else
MsgBox "Error: " & Err.Number & vbCr & Err.Description
Resume Exit_Procedure
End Select
End Sub
Private Sub cmdNextRecord_Click()
On Error GoTo Error_Handler
DoCmd.GoToRecord , , acNext
Exit_Procedure:
On Error Resume Next
Exit Sub
Error_Handler:
Select Case Err
Case Else
MsgBox "Error: " & Err.Number & vbCr & Err.Description
Resume Exit_Procedure
End Select
End Sub
Private Sub cmdLastRecord_Click()
On Error GoTo Error_Handler
DoCmd.GoToRecord , , acLast
Exit_Procedure:
On Error Resume Next
Exit Sub
Error_Handler:
Select Case Err
Case Else
MsgBox "Error: " & Err.Number & vbCr & Err.Description
Resume Exit_Procedure
End Select
End Sub
intermitently kicks out an error "No current record." The help screen
is close to worthless, and hours of searching our newsgroup has only
made me more confused.
The error occurs when I close my form. However, the error does not
occur regularly, it only occurs when I navigate from one record to the
next, using my next record command button. This is to say, if I open
my form, then close it ... no error occurs. Furthermore, the error
does not occur consistently on any particular record. For example, if
I simply navigate to the 3rd record, then the form will close with no
error. However, if I navigate to the last record, back to the first
record, then to the third record, the form will close with the error.
Finally, the error is not trapped in any of my error handlers (which I
have dutifully included on every single sub and function). I have
tried trapping the error in a Form_Unload event, however, the error
occurs before this event. Furthermore, I included Debug.Print
Me.CurrentRecord in the Form_Unload event and I'm getting the proper
record printed, even when the No current record error is generated.
My question: does anyone have a sense of where to start debugging this
problem, or in a perfect world how to fix this?
My suspicion is that the error is being driven by the code in my
Form_Load sub, in particular the RecordsetClone and Bookmark pieces,
which admittedly I am hazy on understanding. The code is included
here:
Private Sub Form_Load()
On Error GoTo Error_Handler
'If this form loads with open args, then the item has already been
'entered and the unit of measure data should not be enabled
'Convoluted load procedure allows navigation buttons to work
If Len(Me.OpenArgs) > 0 Then
'Disable the unit of measure fields
With Me.Item_Unit_of_Measure
.Enabled = False
End With
'Go to proper record and allow navigation buttons to work
With Me.RecordsetClone
.FindFirst "Item_Description_ID = '" &
FindFirstFixup(Me.OpenArgs) & "'"
If .NoMatch Then
MsgBox "Item Not Found", vbOKOnly, "Item Lookup"
Else
Me.Bookmark = .Bookmark
End If
End With
End If
'Update subform windows
DateAnalyze
Exit_Procedure:
On Error Resume Next
Exit Sub
Error_Handler:
Select Case Err
Case Else
MsgBox "Error: " & Err.Number & vbCr & Err.Description
Resume Exit_Procedure
End Select
End Sub
The code in my navigation buttons may also be contributing to the
confusion.
Private Sub cmdFirstRecord_Click()
On Error GoTo Error_Handler
DoCmd.GoToRecord , , acFirst
Exit_Procedure:
On Error Resume Next
Exit Sub
Error_Handler:
Select Case Err
Case Else
MsgBox "Error: " & Err.Number & vbCr & Err.Description
Resume Exit_Procedure
End Select
End Sub
Private Sub cmdPreviousRecord_Click()
On Error GoTo Error_Handler
DoCmd.GoToRecord , , acPrevious
Exit_Procedure:
On Error Resume Next
Exit Sub
Error_Handler:
Select Case Err
Case Else
MsgBox "Error: " & Err.Number & vbCr & Err.Description
Resume Exit_Procedure
End Select
End Sub
Private Sub cmdNextRecord_Click()
On Error GoTo Error_Handler
DoCmd.GoToRecord , , acNext
Exit_Procedure:
On Error Resume Next
Exit Sub
Error_Handler:
Select Case Err
Case Else
MsgBox "Error: " & Err.Number & vbCr & Err.Description
Resume Exit_Procedure
End Select
End Sub
Private Sub cmdLastRecord_Click()
On Error GoTo Error_Handler
DoCmd.GoToRecord , , acLast
Exit_Procedure:
On Error Resume Next
Exit Sub
Error_Handler:
Select Case Err
Case Else
MsgBox "Error: " & Err.Number & vbCr & Err.Description
Resume Exit_Procedure
End Select
End Sub