Results 1 to 5 of 5

Thread: Error Line: 0 / Error: (0)...What is my error??

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    2

    Exclamation Error Line: 0 / Error: (0)...What is my error??

    Hi guys

    I am using VBA to insert some data into a table should the appropriate record exist on a different table.
    I am opening and closing a Recordset to retrieve record values which loops until it gets to the end of the file.
    It goes through the entire loop fine, creates files etc., however, it seems to catch an error at the end and no matter what I try I can't seem to figure out what is causing it!
    I have included the basics of the code...any help on this would be very much appreciated.
    Thanks a lot

    Kate

    VB Code:
    1. sTableName = "SELECT * FROM tblRestaurants"
    2.  
    3.  rs.Open sTableName, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
    4.  rs.MoveFirst
    5.  
    6.  ' Loop to check firstly if the record exists
    7.  ' If it does exist create the appropriate files
    8.  
    9. While Not rs.EOF
    10.  
    11.     counter = counter + 1
    12.     strSQL = sTableName & " WHERE Number=" & counter
    13.     rs2.Open strSQL, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
    14.  
    15.         If rs2.EOF() <> True Then
    16.             recordCount = recordCount + 1
    17.         End If
    18.  
    19.         rs2.Close
    20.         Set rs2 = Nothing
    21.                  
    22.         If recordCount <= 0 Then
    23.    
    24.                 rs.MovePrevious
    25.                
    26.         Else
    27.                 strNewFileName = DLookup("[NewFileName]", "tblRestaurants", "[Number] = " & counter)
    28.                
    29.                     DoCmd.RunSQL "DELETE tmpAPFiles.* FROM tmpAPFiles;"
    30.                     strSQL = "INSERT INTO tmpAPFiles ( UnitID, DocumentDate, RefNum, DocumentNumber, SupplierName, TotalAmount, Field7, GLCode, GLAmount, GLName, PaymentType, ManChequeNum, SupplierAccountNumber, SupplierID, PaymentType2, LastDayOfPWY )SELECT tblAPFiles.UnitID, tblAPFiles.DocumentDate, tblAPFiles.RefNum, tblAPFiles.DocumentNumber, tblAPFiles.SupplierName, tblAPFiles.TotalAmount, tblAPFiles.Field7, tblAPFiles.GLCode, tblAPFiles.GLAmount, tblAPFiles.GLName, tblAPFiles.PaymentType, tblAPFiles.ManChequeNum, tblAPFiles.SupplierAccountNumber, tblAPFiles.SupplierID, tblAPFiles.PaymentType2, tblAPFiles.LastDayOfPWY FROM tblRestaurants INNER JOIN tblAPFiles ON tblRestaurants.RestNum = tblAPFiles.UnitID WHERE (((tblRestaurants.Number)=" & counter & "));"
    31.                     DoCmd.RunSQL strSQL
    32.                     DoCmd.TransferText acExportDelim, , "qrytmpAPFiles", "w:\unitdata\polling\ap\fixed\" & strNewFileName, False
    33.                     recordCount = 0
    34.                    
    35.                 End If                              
    36.         End If
    37.    
    38.  rs.MoveNext
    39.    
    40. Wend
    41.  
    42.  ' Check if the recordset has anything in it
    43.  If (rs Is Nothing) Then
    44.     If rs.State <> 0 Then
    45.         rs.Close
    46.         Set rs = Nothing
    47.     End If
    48. End If
    49.  
    50.  On Error GoTo PROC_ERR    
    51.    
    52. PROC_ERR:
    53.       MsgBox "Error Line: " & Erl & vbCrLf & vbCrLf & "Error: (" & Err.Number & ") " & Err.Description, vbCritical
    54.     Exit Function
    Attached Images Attached Images  

Posting Permissions

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



Click Here to Expand Forum to Full Width