Results 1 to 2 of 2
  1. #1
    ksor's Avatar
    ksor is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Feb 2017
    Posts
    126

    Setting index not posible - why ?

    I have a table storing path to picture files on the disc.



    I have a field for user selected order of the pictures - field name "Sortering".

    I want to insert these picture into a WORD-document in the user defined order and use this code:

    Code:
        Dim tbl As DAO.Recordset
        Set tbl = CurrentDb.OpenRecordset("BILLEDE")
        With tbl
            .Index = .Fields("Sortering")
            .FindFirst "PersonID=" & Me.PersonID
            If .NoMatch Then Exit Sub
            bD.Range(0, 0).Text = "Registrerede billeder:"
            Do
                bD.Range(End:=Selection.End).Text = .Fields("Billedtekst")
                .FindNext "PersonID=" & Me.PersonID
            Loop Until .EOF
        End With
        Set tbl = Nothing
    I have tried to open the recordset as you se here without specification, as a dbOpenSnapshot, as a dbOpenDynaset but
    NOT ALLOWED to set the index in any of these cases - Error 3251 - not allowed for this objecttype !

    I have tried to have the field NOT indexed in the definition, I have tried to HAVE it indexed - same error !

    How can I acces the pictures in the user defined order ?

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    Note: I do not program word with vba, but here is my comment based on Access

    Why not open the table in design mode, then create an index on the field "sortering"?
    No need to build the index in code.

    And/or create a query based on your table and use Order BY sortering
    use the query as the recordset

    eg Set tbl = CurrentDb.OpenRecordset("your query name here",dbOpenDynaset)


    Based on this info(via google)
    If "Costume" is the name of a table, not a stored query, then the recordset opened by


    Set rst = dbs.OpenRecordset("Costume")

    will be a table-type recordset, and the FindFirst method is not supported for that type of recordset. As Mimmo and Daniel have suggested, you can make the recordset be a dynaset by either opening the recordset on a query, or by specifying the dbOpenDynaset option when you open it.


    Dirk Goldgar, MS Access MVP 2001-2015

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

Similar Threads

  1. Atlas Index
    By EHawkins in forum Reports
    Replies: 7
    Last Post: 01-09-2018, 06:59 PM
  2. 'id' is not an index in this table
    By DManders in forum Access
    Replies: 4
    Last Post: 08-18-2015, 04:17 AM
  3. Where is the Index for Table?
    By netchie in forum Access
    Replies: 5
    Last Post: 12-13-2012, 07:53 PM
  4. Access won't set the first index to 1
    By togo in forum Access
    Replies: 5
    Last Post: 10-03-2012, 08:11 PM
  5. Set tab index of controls on tab
    By Deutz in forum Forms
    Replies: 4
    Last Post: 08-09-2011, 08:15 PM

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