Help: subforms with checkbox

claudz_08

Registered User.
Local time
Today, 23:32
Joined
Jun 3, 2003
Messages
17
I need help....what i'm trying to do is that i have this subform list then on its sides there is a corresponding checkbox per row. What i'm trying to do is like the mailbox of yahoo or hotmail. I want to check the checkbox of a designated row then will hit a delete button and voila!...those rows are deleted. How do i do this using subforms and checkbox in ms access?
 
Create a delete query where the 'check' value = true and add this code to the click event of your button...
Code:
Private Sub YourButton_Click()
On Error GoTo Err_YourButton_Click

    Dim stDocName As String

    stDocName = "NameOfYourDeleteQuery"
    DoCmd.OpenQuery stDocName, acNormal, acEdit
    Me.NameOfYourSubform.Requery

Exit_YourButton_Click:
    Exit Sub

Err_YourButton_Click:
    MsgBox Err.Description
    Resume Exit_YourButton_Click
    
End Sub

Hope this helps

IMO
 
Better to give the Yes/No option...
Code:
Private Sub YourButton_Click()

Dim stDocName As String

       If MsgBox("Are you sure you want to delete the selected record?", vbYesNo, "Delete?") = vbYes Then
            stDocName = "YourDeleteQuery"
            DoCmd.OpenQuery stDocName, acNormal, acEdit
            Me.YourSubForm.Requery
        Else
            DoCmd.CancelEvent
        End If

End Sub

IMO
 

Users who are viewing this thread

Back
Top Bottom