Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2006
    Location
    California, USA
    Posts
    55

    Unanswered: MS Access, VB, Toggle Ascend/descend Button

    MS Access, continuous Form, 200 to 600+ records.

    I have a button(SortByDate)
    I have a field(LastUpdate)
    This field primarily holds dates, but may be blank or short text(User may enter a note to themselves)

    I need the button to be a toggle button to sort the records by this LASTUPDATE field.
    Press once, is Ascending
    Press again, is Descending
    or visa versa - Does not matter to ascend or descend first, just must toggle.
    Name on the button does not need to change nor show Icon for up/down (do not need fancy stuff really)

    I am not good at programming(Hardware guy) but I do have some very basic ability.

    Any thoughts or suggestion that would push me in the right direction.. maybe the command to use?? .. Is this a 'Filter' command or is there a 'Sort' command in VB code? Suggested code would be wonderful.

    Thanks in advance

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi Mesa

    Are you stuck with getting your button to do one action on one press and another action on the next press or are you stuck at sorting the records?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Yikes! A lot depends on how everything is constructed ... You could apply a filter ... Or you could "mod" a query ... Tell us how this form is constructed. Is the form bound to a "stored" query?
    Back to Access ... ADO is not the way to go for speed ...

  4. #4
    Join Date
    Aug 2006
    Location
    California, USA
    Posts
    55
    The form is a simple very basic continous form that collects information in 19 fields. I have several text fields operating properly that is sorting records by field content(alphabetically) and working fine.. ie sort by group of 'owner' or by 'location'.

    Again I am not a programmer so every bit of this is very difficult for me... My abilities in this world is very limited.

    The button <I imagine> could be the same and be simply
    Private Sub SortByDate_Click()
    and sorts the long list of LASTUPDATE

    I could live with only having it sort with the oldest dates at the top and not have the toggle feature (empty or text fields go to bottom)
    This allows the user to find the oldest updates quickly.

    Because I am not good here... KISS is good for me.

    Thanks for any help...

  5. #5
    Join Date
    Aug 2006
    Location
    California, USA
    Posts
    55
    I would like to thank thank forum for all the help in my project.

    Regarding the 'toggle' issue, I would like to post the solution I was given.

    Optimially I would have liked one button that would act like a toggle to do the Ascend/Descend function but I am not a good progammer and will live with that I received.

    Here is the solution. There are two routines, one Ascends , one Descends.

    Hope it helps you, If anyone has a suggestion(has to be simple for my feeble mind) It would be greatly appreciated.

    This suggests two buttons... SORTBYDATE1 and SORTBYDATE2.. works great.

    Private Sub SORTBYDATE1_Click()
    Form.OrderBy = "LastUpdate ASC"
    Form.OrderByOn = True
    End Sub

    Private Sub SORTBYDATE2_Click()
    Form.OrderBy = "LastUpdate Desc"
    Form.OrderByOn = True
    End Sub

    Mesa Floyd
    "Don't let yourself become over worked and under-played!"

  6. #6
    Join Date
    Feb 2002
    Posts
    108
    MesaFloyd,
    This will work with one button, it does for me anyway.

    If Me.OrderBy = "LastUpdate" Then
    Me.OrderBy = "LastUpdate desc"
    Else
    Me.OrderBy = "LastUpdate"
    End If
    Me.OrderByOn = True

  7. #7
    Join Date
    Aug 2006
    Location
    California, USA
    Posts
    55
    Hi jkevin,

    Works Perfectly!!!!

    Exactly what I been looking for...(actually been grinding on for about two days now)... your Great!

    I very much appreciate your quick and accurate response.

    Kindest regards,
    Mesa Floyd

Posting Permissions

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