Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 17th, 2004, 01:22 AM
Registered User
 
Join Date: Sep 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anjaneekumarcl
Default help

I'm using VB6 and Access 2000. I have three table in Access and two of which are related in one to may relation. I'm trying to delete from the child table some records through my VB interface. I'm connecting to the database through the code. M able to add new records but not able to delete. I'm not able to join the tables also for deleting the records. If possible please send me the example code for this Please help

the code is given below:

Private Sub cmdDelete_Click()
    'Declare Variables for Connection
    Dim objConn As New ADODB.Connection
    Dim objRS As New ADODB.Recordset
    Dim intResponse As Integer

    'Check IF the User Wants to Delete the Record
    intResponse = MsgBox("Are You Sure To Delete The Agent From Record?", vbYesNo, "Delete Record")

    If intResponse = 6 Then

        'Create Connection
        objConn.Open "dsn=Call_Tracker"
        Set objRS = objConn.Execute("Select * From Tracker")
        objRS.MoveFirst
        Do Until objRS.EOF

            'Create query to Delete From Tracker
            sql1 = "DELETE FROM tracker Where Login_ID =" & txtID.Text

            'Execute SQL statement
            objConn.Execute sql1

            objRS.MoveNext
        Loop

        'Close Connection
        objConn.Close
    End If

    'Load the Form Again
    txtID.Text = ""
    Exit Sub

End Sub

:(









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.