Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    sparker75 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jul 2018
    Posts
    107
    This is the example I took it from https://www.youtube.com/watch?v=80OgXS9nvvM

  2. #17
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,529
    I don't feel like watching a video right now, but you definitely can't specify a value for Controls higher than the count minus one.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #18
    sparker75 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jul 2018
    Posts
    107
    So what is the fix in this code? remove the -1?

    'this Sub Implements sort-buttons in an OptionGroup

    Sub FillButtons(oFrm As Form, oFra As OptionGroup)
    Dim oRS As DAO.Recordset, i As Integer
    Dim oTB As TextBox, oTgl As ToggleButton
    Set oRS = oFrm.RecordsetClone
    For i = 0 To oRS.Fields.Count - 1
    Set oTB = oFrm.Detail.Controls(i)
    Set oTgl = oFra.Controls(i + 1) '0 is its label
    oTB.ControlSource = oRS.Fields(i).Name
    oTgl.Caption = oRS.Fields(i).Name
    oTgl.Left = oTB.Left
    oTgl.Width = oTB.Width
    oTB.Locked = True 'so no editing here
    Next i
    oFrm.AllowAdditions = False 'so no new records here
    DoCmd.Maximize
    End Sub

  4. #19
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,529
    My first thought was to get rid of the +1.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #20
    sparker75 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jul 2018
    Posts
    107
    It did not work for me. So to keep it simple. lets say I add a toggle button. When I depress the button the column sorts Ascending. When I release the toggle it sorts Descending. How would I code this?

    Private Sub Frame61_AfterUpdate()
    ?
    End Sub

  6. #21
    sparker75 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jul 2018
    Posts
    107
    Something like this?

    Private Sub Toggle102_AfterUpdate()
    If Toggle102.Value = True Then
    DoCmd.SetOrderBy OrderNum, DESC
    Else
    DoCmd.SetOrderBy OrderNum, Asc
    End If
    End Sub

  7. #22
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,529
    Never used that, more like:

    Me.OrderBy = "OrderNum DESC"
    Me.OrderByOn = True
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #23
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,991
    Quote Originally Posted by pbaldy View Post
    Never used that, more like:

    Me.OrderBy = "OrderNum DESC"
    Me.OrderByOn = True
    Yup - me too.
    I answered this in the parallel thread here: https://www.accessforums.net/showthr...393#post404393
    Had to check the syntax was still the same using DoCmd.SetOrderBy

    Code:
    Private Sub Toggle102_AfterUpdate()    
    If Toggle102.Value = True Then
        DoCmd.SetOrderBy "OrderNum DESC"
    Else        
        DoCmd.SetOrderBy "OrderNum ASC"
    End If
    
    
    End Sub
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. compile error Method or data member not found
    By gunterbrink in forum Programming
    Replies: 9
    Last Post: 01-23-2017, 09:45 AM
  2. Replies: 3
    Last Post: 12-24-2016, 12:42 PM
  3. Compile Error: Method or data member not found
    By JustinC in forum Programming
    Replies: 4
    Last Post: 11-18-2014, 10:25 AM
  4. compile error method or data member not found???
    By chuman vishal in forum Programming
    Replies: 2
    Last Post: 02-26-2013, 01:57 PM
  5. Compile Error: Method or data member not found
    By subtilty in forum Programming
    Replies: 5
    Last Post: 02-09-2012, 07:56 AM

Tags for this Thread

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