Results 1 to 9 of 9
  1. #1
    Parker is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    76

    Access 2010 - List Box Changing Order in which I ask it to

    Hello everyone,


    I have a list box and a series of 11 fields a user can search by. My problem is that the
    List Box has changed the column order.

    Example: In the design wizard of the list box I had it such that the columns were in order 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11

    Now after I hit search the fields populate out of order... 4, 9, 2, 1, etc...


    Anyone know and easy fix for this?

  2. #2
    Parker is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    76
    This is how my form looks with list box Click image for larger version. 

Name:	Search.png 
Views:	12 
Size:	23.9 KB 
ID:	16481

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Your search button changes the RowSource for your listbox?

    Maybe you can adjust the order of the SQL SELECT statement that is generated by your search button.

  4. #4
    Parker is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    76
    Private Sub Search_Fields_Click()
    RequeryReportList
    End Sub
    Private Sub RequeryReportList()
    Dim Wh As String
    Dim SQL As String
    Wh = ""
    If First_Name <> "" Then
    If Wh <> "" Then Wh = Wh & " " & AndOrCombo & " "
    Wh = "First_Name LIKE '*" & First_Name & "*'"
    End If
    If Last_Name <> "" Then
    If Wh <> "" Then Wh = Wh & " " & AndOrCombo & " "
    Wh = "Last_Name LIKE '*" & Last_Name & "*'"
    End If
    If Date_Report_Submitted <> "" Then
    If Wh <> "" Then Wh = Wh & " " & AndOrCombo & " "
    Wh = "Date_Report_Submitted LIKE '*" & Date_Report_Submitted & "*'"
    End If
    If Report_Title <> "" Then
    If Wh <> "" Then Wh = Wh & " " & AndOrCombo & " "
    Wh = "Report_Title LIKE '*" & Report_Title & "*'"
    End If
    If Report_History_Type <> "" Then
    If Wh <> "" Then Wh = Wh & " " & AndOrCombo & " "
    Wh = "Report_History_Type LIKE '*" & Report_History_Type & "*'"
    End If
    If Approved <> "" Then
    If Wh <> "" Then Wh = Wh & " " & AndOrCombo & " "
    Wh = "Approved LIKE '*" & Approved & "*'"
    End If
    If Department_Number <> "" Then
    If Wh <> "" Then Wh = Wh & " " & AndOrCombo & " "
    Wh = "Department_Number LIKE '*" & Department_Number & "*'"
    End If
    If Abstract <> "" Then
    If Wh <> "" Then Wh = Wh & " " & AndOrCombo & " "
    Wh = "Abstract LIKE '*" & Abstract & "*'"
    End If
    Me.RecordSource = SQL
    SQL = "SELECT * FROM SearchDBQ WHERE " & Wh
    ReportList.RowSource = SQL
    End Sub
    Private Sub Clear_Fields_Click()
    First_Name = ""
    Last_Name = ""
    Date_Report_Submitted = ""
    Report_Title = ""
    Report_History_Type = ""
    Approved = ""
    Department_Number = ""
    Abstract = ""
    ReportList.RowSource = ""
    End Sub
    Private Sub ReportList_DblClick(Cancel As Integer)
    If IsNull(ReportList) Then Exit Sub
    DoCmd.OpenForm "NewLabReportF", , , "Report_ID= ReportList"
    End Sub



    This is all of my code

  5. #5
    Parker is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    76
    This is row source on list box:


    SELECT [SearchDBQ].[Department_Number], [SearchDBQ].[First_Name], [SearchDBQ].[Last_Name], [SearchDBQ].[Date_Report_Submitted], [SearchDBQ].[Report_Title], [SearchDBQ].[Report_History_Type], [SearchDBQ].[Approved] FROM SearchDBQ;



    I want list box to have the following order:

    Department NUmber
    First Name
    Last Name
    Date Report Submitted
    Report Title
    Report History Type
    Approved

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Your issue is here
    Me.RecordSource = SQL
    SQL = "SELECT * FROM SearchDBQ WHERE " & Wh
    ReportList.RowSource = SQL

    So maybe

    SQL = "SELECT [SearchDBQ].[Department_Number], [SearchDBQ].[First_Name], [SearchDBQ].[Last_Name], [SearchDBQ].[Date_Report_Submitted], [SearchDBQ].[Report_Title], [SearchDBQ].[Report_History_Type], [SearchDBQ].[Approved] FROM SearchDBQ WHERE " & Wh
    ReportList.RowSource = SQL

  7. #7
    Parker is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    76
    Where do I type that in or make the changes?

  8. #8
    Parker is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    76
    Solved thank yoU!

  9. #9
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Sure thing

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

Similar Threads

  1. Replies: 1
    Last Post: 03-09-2014, 05:21 AM
  2. Changing order by using code
    By FRAZ in forum Queries
    Replies: 4
    Last Post: 01-22-2014, 12:54 PM
  3. Replies: 9
    Last Post: 05-07-2013, 08:37 PM
  4. Replies: 3
    Last Post: 10-04-2012, 11:38 AM
  5. Replies: 0
    Last Post: 07-31-2012, 12:25 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