Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2007
    Posts
    93

    Unanswered: recordset problem

    hello folks !!!

    i am trying to work around with record set but wonder were i am going wrong ...

    here is the code...


    Private Sub Import_Click()
    On Error GoTo Error_ImportItemSales
    Dim strLine As String
    Dim strSalesman As String
    Dim rst As dao.Recordset
    Dim lngrecord As Long

    If MsgBox("Delete all Item Sales Records", vbQuestion + vbDefaultButton2 + vbYesNo) = vbYes Then
    CurrentDb.Execute ("DELETE * FROM Item_Sales")
    End If

    Set rst = CurrentDb.OpenRecordset("Item_Sales")
    Open CurrentProject.Path & "x.txt" For Input As #1 ' Open file for input.
    'Open "C:\11\invsales.txt" For Input As #1 ' Open file for input.
    Do While Not EOF(1) ' Loop until end of file.
    Line Input #1, strLine
    'Debug.Print strLine
    lngrecord = lngrecord + 1
    rst.AddNew
    rst!Invoice_Date = Trim(Left(strLine, 10))
    rst!Order_No = Trim(Mid(strLine, 11, 8))
    rst!Product_Line = Mid(strLine, 19, 3)
    rst!Item_Code = Mid(strLine, 22, 10)
    rst!Category = Mid(strLine, 32, 3)
    rst!Cust_No = Mid(strLine, 35, 8)
    If Trim(Mid(strLine, 43, 2)) <> "" Then rst!Salesman = Mid(strLine, 43, 2)
    rst!Quantity = Mid(strLine, 45, 6)
    rst!Cost_Price = Mid(strLine, 51, 9)
    rst!Sale_Price = Mid(strLine, 60, 9)
    rst!Invoice_No = Mid(strLine, 69, 7)
    rst!Line_No = Mid(strLine, 76, 3)
    rst!Location_No = Mid(strLine, 79, 1)
    If Trim(Mid(strLine, 80, 7)) <> "" Then
    rst!RMA_No = rst!Order_No
    rst!Order_No = Trim(Mid(strLine, 80, 7))
    End If
    rst!Period_Date = DateAdd("m", 1, DateSerial(Year(rst!Invoice_Date), Month(rst!Invoice_Date), 1)) - 1
    rst.Update
    'Debug.Print Trim(Left(strLine, 10))
    Loop
    Close #1 ' Close file.
    MsgBox "Import Completed"
    Exit Sub
    Error_ImportItemSales:
    If Err.Number = 3218 Then
    Err.Clear
    Resume
    End If
    Exit Sub
    End Sub



    the above code was working until yesterdy bt since today its not working .. dont know y ..
    or is it possible the rst is stil opn and isnt letting it to fuction ???

    any help would be appreciated
    Last edited by sam_01; 03-09-09 at 15:25.

  2. #2
    Join Date
    May 2005
    Posts
    1,191
    What line is it failing on?

    Else, I would try doing
    Code:
    rst.close
    set rst = nothing
    
    Exit Sub
    
    Error_ImportItemSales:
        If Err.Number = 3218 Then
            Err.Clear
            Resume
        End If
        on error resume next
        rst.close
        set rst = nothing
        Exit Sub
    
    End Sub
    Me.Geek = True

  3. #3
    Join Date
    Nov 2007
    Posts
    93
    there isnt any error

    its just going blank and diong nothing ..
    when i debugged and checked the rst.. then its shows nothing
    rst=nothing

    any clue ???

  4. #4
    Join Date
    May 2005
    Posts
    1,191
    dumb question maybe, but are you sure the table is still there?
    Else, try explicitly specifying the recordset type like:
    Code:
    Set rst = CurrentDb.OpenRecordset("Item_Sales", dbOpenTable)
    Me.Geek = True

  5. #5
    Join Date
    May 2005
    Posts
    1,191
    Otherwise, make sure you don't have a conflicting reference with ADO. Worth a look anyways.
    Me.Geek = True

  6. #6
    Join Date
    Nov 2007
    Posts
    93
    thanks for the prompt reply


    i checked all the references .. but of no use and the table does exist. as the table is getting cleared and in my opinion the problem is from this line of code

    set rst=...//

    stil any suggestions ... ???
    Last edited by sam_01; 03-09-09 at 16:43.

  7. #7
    Join Date
    May 2005
    Posts
    1,191
    I think I told you wrong earlier, try
    Set rst = CurrentDb.OpenRecordset("Item_Sales", dbOpenDynaset)
    for adding a record, maybe?
    Me.Geek = True

  8. #8
    Join Date
    Nov 2007
    Posts
    93
    i tried with the option ... but nothing shows up

    stil struct at the same position

    any clues ??

Posting Permissions

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