Results 1 to 3 of 3
  1. #1
    walter189 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2011
    Posts
    7

    OrderBy Not working for select few cases

    I have a subroutine that sets up how i want my records to be sorted when my report is opened. Type1 is a combobox on my form, go ahead and ignore the Arrow stuff. All these cases will order correctly except for %IR, %IX, %IZ. The only thing I can think of is that it has something to do with having a percent sign (%) as the leading character of my field. Perhaps the OrderBy property will not allow symbols like these as leading characters in a string? Any thoughts would be excellent as I'm spent and can't think of what else the issue may be.


    Public Sub SortHowStats()
    ArrowsOff
    Reports!StatsOnly.OrderByOn = True
    Select Case Me.Type1
    Case "Core Loss"
    Reports!StatsOnly!ArrowCore.Visible = True


    Reports!StatsOnly.OrderBy = Me.Type1
    Case "Conductor Loss"
    Reports!StatsOnly!ArrowLoad.Visible = True
    Reports!StatsOnly.OrderBy = Me.Type1
    Case "Total Loss"
    Reports!StatsOnly!ArrowTotal.Visible = True
    Reports!StatsOnly.OrderBy = Me.Type1
    Case "100% Voltage Excitation Current"
    Reports!StatsOnly!ArrowEC.Visible = True
    Reports!StatsOnly.OrderBy = "Excitation Current"
    Case "Load/Conductor Losses 50% Load"
    Reports!StatsOnly!ArrowLoad50.Visible = True
    Reports!StatsOnly.OrderBy = Me.Type1
    Case "Total Loss 50% Load"
    Reports!StatsOnly!ArrowTotal50.Visible = True
    Reports!StatsOnly.OrderBy = Me.Type1
    Case "Efficiency @ 100% Load"
    Reports!StatsOnly!ArrowEfficiency100.Visible = True
    Reports!StatsOnly.OrderBy = Me.Type1
    Case "Efficiency @ 50% Load"
    Reports!StatsOnly!ArrowEfficiency50.Visible = True
    Reports!StatsOnly.OrderBy = Me.Type1
    Case "%IR"
    Reports!StatsOnly!ArrowIR.Visible = True
    Reports!StatsOnly.OrderBy = Me.Type1
    Case "%IX"
    Reports!StatsOnly!ArrowIX.Visible = True
    Reports!StatsOnly.OrderBy = Me.Type1
    Case "%IZ"
    Reports!StatsOnly!ArrowIZ.Visible = True
    Reports!StatsOnly.OrderBy = Me.Type1
    Case "% Regulation @ PF=0.8"
    Reports!StatsOnly!ArrowRegEight.Visible = True
    Reports!StatsOnly.OrderBy = "RegEight"
    Case "% Regulation @ PF=1.0"
    Reports!StatsOnly!ArrowRegOne.Visible = True
    Reports!StatsOnly.OrderBy = "RegOne"
    Case Else
    Reports!StatsOnly.OrderByOn = False
    End Select
    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    I think % is a wildcard in SQL but don't know what VBA thinks of it. Field names begin with %? If this is the case, need to enclose in [].

    Case "%IZ"
    Reports!StatsOnly!ArrowIZ.Visible = True
    Reports!StatsOnly.OrderBy = "[" & Me.Type1 & "]"

    Are you sure that cases where the OrderBy field has spaces are working?

    I NEVER use symbols, punctuation, spaces in names, if do, need [].
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    walter189 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2011
    Posts
    7
    Thank you very much!!! I should have figured that and thanks for the suggestion about NOT using symbols and other stuff in names, i'll need to get better about that.

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

Similar Threads

  1. prompt for orderby in report
    By nkuebelbeck in forum Access
    Replies: 2
    Last Post: 08-18-2011, 12:57 PM
  2. Form Filter/OrderBy Issue
    By Gray in forum Forms
    Replies: 2
    Last Post: 05-13-2011, 03:10 PM
  3. Replies: 8
    Last Post: 04-21-2011, 05:29 PM
  4. OrderBy Losing Criteria
    By P5C768 in forum Forms
    Replies: 1
    Last Post: 01-21-2011, 01:07 PM
  5. SELECT DISTINCT not working
    By johnmerlino in forum Queries
    Replies: 2
    Last Post: 10-25-2010, 06:48 PM

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