Results 1 to 5 of 5
  1. #1
    UserX is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2014
    Posts
    30

    "Order By..." code causes record mismatch?

    I am very near completion of my new database, thanks to very insightful knowledge of June7 and Pbaldy, of course. My goal is to be able to select multiple records and append those selected records at the same time. Pbaldy gave me the idea (and code) to bring about a multiselect listbox. My listbox can either have the TimeHelped field editable by double clicking the record, and then typing the time value into the TimeHelped textbox below the listbox, which is what I want. The problem is that the listbox always sorts the record list alphabetically by customer's last name. My feeble attempt to fix this problem was to specify "Record Source = SELECT * FROM tblSign_in Order By Time_In DESC". Though this did sort the records from highest to lowest, the TimeHelped field, when updated, does not match the record selected. For example, in a list of five records, sorted by Time_In, from highest to lowest, the following results happened:

    5. Updates record 1
    4. Updates record 2
    3. Updates record 3
    2. Updates record 4


    1. Creates new record entry with just the TimeHelped value

    If someone would help me make sense of this, or suggest an alternative method of accomplishing my sorting, I would be eternally grateful. Attached is a sample of my db.
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Which form is involved in the issue?
    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
    UserX is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2014
    Posts
    30
    forgive me. open nav pane, and open frmSI

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Suggest using the unique ID field in tblSign_in to identify the record to update then run an UPDATE sql instead of trying to find and edit a record in recordset. Why hide fields in the table?

    Include the ID field as column in listbox. Then:

    CurrentDb.Execute "UPDATE tblSign_in SET TimeHelped=#" & Me.Txt69 & "# WHERE ID=" & Me.Lst60.Column(x)

    Then requery the listbox.

    The TimeHelped input does not indicate AM/PM. Possibly Access will default to AM. Unless the input is 24-hour clock structure - is that what you intend?
    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.

  5. #5
    UserX is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2014
    Posts
    30
    June7, you're awesome! That works perfectly. Thank you so much!

    I don't really remember why I hid the fields on the table. Using the 24-hour clock style is what we do here, so this works perfectly. Thank you again.

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

Similar Threads

  1. Replies: 2
    Last Post: 10-01-2012, 06:47 PM
  2. Replies: 0
    Last Post: 01-11-2012, 12:34 PM
  3. Replies: 1
    Last Post: 08-05-2011, 12:05 PM
  4. Replies: 2
    Last Post: 05-17-2011, 02:40 PM
  5. aSTR = Dir("C:\*.*") >> "Type Mismatch"
    By JGrant in forum Programming
    Replies: 1
    Last Post: 03-28-2009, 05:17 AM

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