Results 1 to 2 of 2
  1. #1
    rashima is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    16

    timeout expired error

    I have a delete button which first deleting data from child table based on choosed record from access form and then it should delete also parent record from main table.

    its doing deletion from child table quickly but when it goes to next line to delete parent record it gives error of timeout expired

    frontend--> access
    backend--> sql-server

    code is here, any help will be appriciated..........please help
    Private Sub cmd_DeleteRecords_Click()
    On Error GoTo Err_cmd_DeleteRecords_Click
    Dim I As Long
    Dim F As Form
    Dim ii As Long
    Dim sRepAttDetID As Variant
    Dim rs As ADODB.Recordset
    Dim rsdetail As New ADODB.Recordset
    Dim RunSelect16Cmd As New ADODB.Command
    Dim rsRepAttrList As New ADODB.Recordset
    Dim RunSelect17Cmd As New ADODB.Command
    Dim rsRepAttrList1 As New ADODB.Recordset
    If MsgBox("Do you really want to delete selected records", vbOKCancel, "Records Deletion") = vbOK Then
    Set F = Forms!frm_maingui!NavigationSubform.Form
    'Set F = Forms!Frm_Reports
    Set rs = F.RecordsetClone
    If rs.RecordCount <= 0 Then
    Exit Sub
    End If
    rs.MoveFirst
    rs.Move IntSelTop - 1

    For I = 1 To IntSelHeight
    sRepAttDetID = rs![Detail_ID]
    InitCommand RunSelect16Cmd, "DELETE FROM Tbl_AttributeDetail where Detail_ID= " & sRepAttDetID & " "
    Set rsRepAttrList = ExecuteCommand(RunSelect16Cmd)

    InitCommand RunSelect17Cmd, "DELETE FROM Tbl_Detail where Detail_ID= " & sRepAttDetID & " "
    Set rsRepAttrList1 = ExecuteCommand(RunSelect17Cmd)
    rs.MoveNext
    Next I

    Else
    MsgBox "cancel"
    End If


    Set RunSelect16Cmd = Nothing
    Set rsRepAttrList = Nothing
    Set RunSelect17Cmd = Nothing
    Set rsRepAttrList1 = Nothing
    Exit_cmd_DeleteRecords_Click:
    Exit Sub
    Err_cmd_DeleteRecords_Click:
    MsgBox Err.Description
    Resume Exit_cmd_DeleteRecords_Click

    End Sub

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Do these tables have relationship set up? Is Cascade Delete checked on in the relationship setting? If so, should just delete the parent and the related child records will also delete. However, I've never put it to the test.

    Could try simplifying the code. What is InitCommand RunSelect16Cmd? I don't understand Set rsRepAttrList ExecuteCommand(RunSelect16Cmd). I've never done anything like that. I just:
    CurrentDb.Execute "DELETE FROM Tbl_AttributeDetail where Detail_ID= " & sRepAttDetID

    Why delete records anyway? I have one situation where users are allowed to delete records so as to adjust tests selected to be conducted on a sample, otherwise, records are never deleted.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. ODBC timeout message on query
    By thart21 in forum Queries
    Replies: 3
    Last Post: 08-05-2011, 08:54 AM
  2. Timeout Expired
    By Raj in forum Access
    Replies: 3
    Last Post: 05-04-2011, 09:51 PM
  3. Expired Date Query Design
    By Bike in forum Queries
    Replies: 4
    Last Post: 03-30-2011, 02:46 PM
  4. Linked Table and S1T00 timeout error
    By Jack A in forum Access
    Replies: 1
    Last Post: 01-22-2010, 09:14 PM
  5. Timeout Expired
    By brvaland in forum Database Design
    Replies: 0
    Last Post: 04-03-2009, 04:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums