Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2004
    Posts
    10

    Unanswered: Deleting/Creating a Subform Record

    I would like to create 2 menu options that delete and create a record in teh subform of a main form.

    I have created the 2 menu options with the relevant macros it is just the coding I require to acheive this.

  2. #2
    Join Date
    Jun 2003
    Location
    USA
    Posts
    1,032
    Some code to possibly get you started:

    Code:
    Public Function tlbDelete()
        ' Purpose:  Delete current record if there is one.
        ' Remarks:  Called by button on toolbar.
    
        On Error GoTo Err_tlbDelete
        
        ' Dim var.
        Dim frm As Form
    
        If Application.CurrentObjectType = acForm Then
            ' Set var.
            Set frm = Screen.ActiveForm
        
            ' Delete cur rec (or just undo if it's a new rec - i.e. never been saved).
            If frm.NewRecord Then
                ' Undo cur rec.
                frm.Undo
            Else
                ' Delete rec.
                DoCmd.RunCommand acCmdDeleteRecord
            End If
        Else
            ' Delete rec.
            DoCmd.RunCommand acCmdDeleteRecord
        End If
        
        Exit Function
    
    Err_tlbDelete:
        Exit Function
    
    End Function
    
    Public Function tlbNew()
        ' Purpose:  Go to a new rec.
        ' Remarks:  Called by button on toolbar.
    
        On Error GoTo Err_tlbNew
        
        ' Go to a new rec (Records | Go to | New).
        DoCmd.RunCommand acCmdRecordsGoToNew
        
        Exit Function
    
    Err_tlbNew:
        Exit Function
    
    End Function
    J. Paul Schmidt, Freelance Web and Database Developer
    www.Bullschmidt.com
    Access Database Sample, Web Database Sample, ASP Design Tips

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •