dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Run time error '3265' item not found in this collection

  1. #1
    Join Date
    Jul 2011
    Posts
    3

    Run time error '3265' item not found in this collection

    well,,
    somebody can help me??
    i try to solve my problem for 2 days
    i don't know where's the error
    always item not found in this collection
    i want ask to u
    what's wrong in this below syntax

    DtBeli.RecordSource = "SELECT * FROM Pembelian WHERE ID_BELI= 'XXXXXXXX' AND ID_BARANG = ' " & TxtIDBarang.Text & " ' AND ID_SUPPLIER = ' " & TxtIDSupplier.Text & " ' "

    what's wrong with it?
    i really don't know how to select from 3 tables,,
    bcz i'm a beginner in programming
    plz help me

  2. #2
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,317

    Re: Run time error '3265' item not found in this collection

    Your syntax looks fine. If that line is the one throwing the error then it would indicate that either the table Pembelian does not exist or is not spelled properly or one of the three fields named is not correct.

    You mention selecting from 3 tables, if those occuring after the where are in different tables or are table names then the statement is way off. To select from multiple tables you must use a Join statement.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Jul 2011
    Posts
    3

    Re: Run time error '3265' item not found in this collection

    i dont know how to use join on 3 tables
    can u help me???
    how to use join in my syntax?

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Run time error '3265' item not found in this collection

    Look up SQL BOOKS ONLINE for syntax. This *might* help:
    Code:
    Private Sub Command1_Click()
        Dim cnLvConnection As ADODB.Connection
        Set cnLvConnection = New ADODB.Connection
        Dim rsLvRecordset As ADODB.Recordset
        Set rsLvRecordset = New ADODB.Recordset
        With cnLvConnection
            .Provider = "MSDataShape.1"
            .ConnectionString = "Data Source=" & App.Path & "\db1.mdb;" _
                              & "Data Provider=Microsoft.Jet.OLEDB.4.0;"
            .Open
            With rsLvRecordset
                .CursorLocation = adUseClient
                .CursorType = adOpenStatic
                .LockType = adLockReadOnly
            End With
            Set rsLvRecordset = .Execute("SHAPE {SELECT c.CustomerName As Customer, c.CustomerID FROM Customers c ORDER BY c.CustomerName} As Customers" _
                                       & " APPEND ((SHAPE {SELECT oh.OrderNumber As [Order No], oh.CustomerID, oh.OrderHeaderID FROM OrderHeaders oh ORDER BY oh.OrderNumber} As OrderHeaders" _
                                       & "          APPEND ({SELECT od.OrderLine As [Line], od.OrderLineDescription As [Description], od.OrderLineQuantity As Quantity, od.OrderHeaderID FROM OrderDetails od ORDER BY od.OrderLine} As OrderDetails" _
                                       & "          RELATE OrderHeaderID TO OrderHeaderID))" _
                                       & " RELATE CustomerID TO CustomerID)")
        End With
        '   Setup Grid
        Set Me.MSHFlexGrid1.Recordset = rsLvRecordset
        Me.MSHFlexGrid1.ColWidth(1, 0) = 0 ' c.CustomerID
        Me.MSHFlexGrid1.ColWidth(1, 1) = 0 ' oh.CustomerID
        Me.MSHFlexGrid1.ColWidth(2, 1) = 0 ' oh.OrderHeaderID
        Me.MSHFlexGrid1.ColWidth(3, 2) = 0 ' od.OrderHeaderID
        '   Tidy up
        If Not rsLvRecordset Is Nothing Then
            If rsLvRecordset.State <> adStateClosed Then
                rsLvRecordset.Close
            End If
            Set rsLvRecordset = Nothing
        End If
        If Not cnLvConnection Is Nothing Then
            If cnLvConnection.State <> adStateClosed Then
                cnLvConnection.Close
            End If
            Set cnLvConnection = Nothing
        End If
    End Sub
    
    Private Sub Form_Load()
        Me.MSHFlexGrid1.FixedCols = 0
    End Sub
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,317

    Re: Run time error '3265' item not found in this collection

    Quote Originally Posted by junita92 View Post
    i dont know how to use join on 3 tables
    can u help me???
    how to use join in my syntax?
    It is not possible to show you the proper syntax to join 3 for your statement as you did not provide the required info. Your statement looks like it is selecting all fields from one table based on the values of 3 fields in that same table. If this is the intended result then your statement is ok. If the intention is to pull data from more than one table or based on values in more than one table then we would have to know the names of the tables and the names of the key fields which will be joined.

    For example in an order system you may have a table called Customers and another called Orders both tables may have a field named CustomerID which will allow you to get the customer info for a given order based on the ID in the order table.

    Code:
    "Select * from customers inner join Orders.CustomerID on Customers.CustomerID where Orders.OrderNumber=" & OrderNumber
    The query above will return rows containing all the data for the given customer from the customers table as well as all the data from the orders table where ordernumber is equal to the one given but only it the customer number matches an entry in the customers table
    Last edited by DataMiser; July 9th, 2011 at 07:08 AM.
    Always use [code][/code] tags when posting code.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)