I have an Access 97 Database. I use 3 buttons. Next Record, Previous Record and New Record. When I click the new record to establish a new child record I get an error. If the parent has NO child records, the error does not show up.
Code behind Next & Previous is:
Private Sub Form_Current()
Dim recClone As Recordset
Dim intNewRecord As Integer
‘ Make a clone of the recordset underlying the form so
‘ we can move around that without affecting the form’s
‘ recordset
Set recClone =Me.RecordsetClone
‘ But we need to check if there are no records. If so,
‘ we disable all the buttons except for the
If recClone.RecordCount = 0 Then
[CMDNextDepend].Enabled = False
[Cmd Previous].Enabled = FalseElse
‘Synchonise the current pointer in the two recordsets
recClone.Bookmark = Me.Bookmark
‘ If there are records, see if we are on the first record
‘ If so, we should disable the
recClone.MovePrevious
[Cmd Previous].Enabled = Not (recClone.BOF)
recClone.MoveNext
‘ And then check whether we are on the last record
‘ If so, we should disable the
recClone.MoveNext
[CMDNextDepend].Enabled = Not (recClone.EOF)
recClone.MovePrevious
End If
‘ And finally close the cloned recordset
recClone.Close
End Sub
ERROR COMES UP IN THE ABOVE MODULE!!!!!
Code behind the New Record button is:
Private Sub CmdNewDepend_Click()
On Error GoTo Err_CmdNewDepend_Click DoCmd.GoToRecord , , acNewRec
Exit_CmdNewDepend_Click:
Exit Sub
Err_CmdNewDepend_Click:
MsgBox Err.Description
Resume Exit_CmdNewDepend_Click
End Sub
THANKS FOR ANY HELP YOU CAN OFFER!
Alan