Results 1 to 2 of 2
  1. #1
    zzoemie is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2021
    Posts
    1

    Data Not Sorted Correctly In A Listbox

    Hi,

    I am using the following code to populate a listbox:

    strsql = "SELECT tblObservaties.AutoID, tblObservaties.Datum, tblObservaties.C_OntwVelden, [02_Ontwikkelthemas].Ontwikkelthema, [03_Generieke doelen].[Generiek doel], " _
    & "[04_ObservatieItems].Omschrijving, tblObservaties.Alg, tblObservaties.C_GrF, [04_ObservatieItems].C_Gen_Doel, tblObservaties.C_Observatie " _
    & "FROM tblSoortenOntwikkeling INNER JOIN ((((tblObservaties INNER JOIN 01_Ontwikkelvelden ON tblObservaties.C_OntwVelden = [01_Ontwikkelvelden].C_OntwVelden) " _
    & "INNER JOIN 02_Ontwikkelthemas ON (tblObservaties.[C_OntwThema's] = [02_Ontwikkelthemas].[C_OntwThema's]) AND ([01_Ontwikkelvelden].C_OntwVelden = [02_Ontwikkelthemas].C_OntwVelden)) " _
    & "INNER JOIN [03_Generieke doelen] ON ([01_Ontwikkelvelden].C_OntwVelden = [03_Generieke doelen].C_OntwVelden) " _
    & "AND ([02_Ontwikkelthemas].[C_OntwThema's] = [03_Generieke doelen].[C_OntwThema's])) INNER JOIN 04_ObservatieItems ON (tblObservaties.C_Observatie = [04_ObservatieItems].C_Observatie) " _
    & "AND ([01_Ontwikkelvelden].C_OntwVelden = [04_ObservatieItems].C_OntwVelden) AND ([02_Ontwikkelthemas].[C_OntwThema's] = [04_ObservatieItems].[C_OntwThema's]) " _
    & "AND ([03_Generieke doelen].C_Gen_Doel = [04_ObservatieItems].C_Gen_Doel)) ON tblSoortenOntwikkeling.S_Ontw = [01_Ontwikkelvelden].S_Ontw " _
    & "WHERE (((tblObservaties.Verantwoordelijke) = '" & GlbInitialen & "') " _
    & "And ((tblObservaties.KleuterID) = '" & GlbKleuterID & "') " _
    & "And ((tblObservaties.Schooljaar) = '" & GlbSchooljaarKort & "') " _
    & "And ((tblObservaties.Graad) = '" & GlbGraad & "')) " _
    & "ORDER BY [01_Ontwikkelvelden].S_Ontw_Sort, tblObservaties.NumDatum DESC , tblObservaties.C_Gen_Doel;"



    'CopyTextToClipboard (strsql)

    LstObservaties.RowSource = strsql
    strsql = Empty

    On the form, the data shown in the listbox is not sorted correctly after executing the above script.
    If I look at the data source, so the query, they are correct.
    I then have the option to click on a line in the list box so that the individual data is put back in the respective fields of the form to make any adjustments.
    After this action I have the listbox filled again with the same procedure and then they will be correct.
    What could be the reason for this?
    You can clearly see the difference on the attached file


    Your advice please.
    Attached thumbnails

    Wrong:
    Click image for larger version. 

Name:	Fout.jpg 
Views:	16 
Size:	142.1 KB 
ID:	43924

    right:
    Click image for larger version. 

Name:	right.jpg 
Views:	15 
Size:	143.9 KB 
ID:	43925

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    without being able to see the values for

    [01_Ontwikkelvelden].S_Ontw_Sort, tblObservaties.NumDatum and tblObservaties.C_Gen_Doel

    how do you expect us to work out what the problem is?

    the last 3 columns have no headings and I struggle to understand the order based on them

    - for SErv04 on the last column why should 01-003 come before 09-003, but after 06-017
    - for MZkm02 (null first column) on the last column why should 04-021 come after 04-019 but before 04-015

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

Similar Threads

  1. Transfer form listbox data to Report listbox.
    By onlylonely in forum Reports
    Replies: 6
    Last Post: 10-08-2017, 07:14 PM
  2. Replies: 0
    Last Post: 05-31-2016, 01:54 PM
  3. Replies: 2
    Last Post: 07-19-2015, 03:51 PM
  4. Replies: 4
    Last Post: 02-02-2015, 07:47 PM
  5. Listbox won't display time correctly
    By UserX in forum Access
    Replies: 7
    Last Post: 06-26-2014, 05:39 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