Results 1 to 3 of 3
  1. #1
    geraldk is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    49

    List Box

    I have a list box in a form that from a query:



    Code:
    SELECT tblEmpVac.EMPID, tblEmpVac.VACID, tblEmpVac.EMPVACDate, tblVacation.PERID, tblEmpVac.EMPVACID
    FROM tblVacation INNER JOIN tblEmpVac ON tblVacation.VACID = tblEmpVac.VACID
    WHERE (((tblEmpVac.EMPID)=1) AND ((tblVacation.PERID)=1));
    What I want to do is find the last tblEmpVac.EMPVACID number (end of record) and then select the date.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    You could ORDER BY VACID DESC then select the first item in the list.
    If IsNull(Me.lstBox) Then
    Me.lstBox = Me.lstBox.ItemData(0)
    End If

    If you don't want to order by desc then need to know the count of items in the listbox. Try using ListCount property, maybe like
    Me.lstBox = Me.lstBox.ItemData(Me.lstBox.ListCount - 1)
    or
    Me.lstBox.Selected(Me.lstBox.ListCount) = True
    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
    geraldk is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    49
    Thanks for the reply.

    I ended up using this command:

    Me.lstPerfect = Me.lstPerfect.ItemData(Me.lstPerfect.ListCount - 1)

    and I sorted the date from latest first in the query to sort out.

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

Similar Threads

  1. Replies: 4
    Last Post: 06-16-2011, 09:30 PM
  2. Replies: 1
    Last Post: 10-22-2010, 10:11 AM
  3. Input data from one list box to another list box
    By KellyR in forum Programming
    Replies: 0
    Last Post: 06-04-2010, 11:24 AM
  4. Replies: 3
    Last Post: 03-25-2010, 12:31 PM
  5. List box to populate other list boxes
    By Nathan in forum Forms
    Replies: 0
    Last Post: 03-03-2009, 07:22 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