Results 1 to 3 of 3
  1. #1
    Delta729 is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Nov 2010
    Location
    Los Angeles
    Posts
    95

    Set default value for listbox for form load

    I'm pretty much a complete novice here so I hope I explain this correctly. I have a form with a list box used to filter data for only "Open" or "Closed". This form works fine, but what I'd like to do is that when the form loads, for it automatically select "Open". The listbox is called lstTaskStatus.




    Here is the sql for the form in case I need to put code in here somewhere.

    SELECT tblObjective.SourceName, tblObjective.Objective, tblObjective.[Relationship Lead], tblObjective.[Management Lead], tblObjective.[Contract Start Date], tblObjective.[Contract End Date], tblObjective.Status, tblTask.[Task/Deliverable], tblTask.Staff, tblTask.[Start Date], tblTask.[Due Date], tblTask.[Completed Date], tblTask.Notes, DateDiff("m",[tblObjective]![Contract Start Date],[tblObjective]![Contract End Date]) & " Months" AS [Contract Duration], tblTask.[Task Status]
    FROM tblObjective LEFT JOIN tblTask ON tblObjective.ObjectiveID = tblTask.ObjectiveID
    WHERE (((tblTask.[Task/Deliverable]) Is Not Null) AND ((tblTask.[Task Status])=[Forms]![frmqryTaskList]![lstTaskStatus]))
    ORDER BY tblTask.[Due Date];

    Any help would be greatly appreciated. Thanks,
    Dan

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    This is an UNBOUND listbox? Did you try setting its DefaultValue property?

    Is frmqryTaskList a text field? Or a yes/no field?

    Do you want the form to open filtered to the "Open" records?


    I never use dynamic parameterized query. I use VBA that builds filter criteria and applies to form Filter property.

    Review http://www.allenbrowne.com/ser-62code.html
    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
    Delta729 is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Nov 2010
    Location
    Los Angeles
    Posts
    95
    Yes, the lstTaskStatus is an unbound listbox. It is on the form named frmqryTaskList. (I know, my naming conventions have something to be desired, but it's the only way I can relate the forms to the queries.) I do have the default value set to open, but when the form loads it only shades the open selection, and doesn't load the form with the "open" records. I still have to click the open to have them viewable.

    ... I started "trying" to answer your questions and then thought I'd try something. Since the "Open" is already selected when the form loads, I just needed to add the me.requery code on the on load event. (I left what I starting typing at the first part of the response in case it helps someone else.)

    Thanks, your questions led me down the correct road again. You helped me out the other day too.

    Thanks again. Very much appreciated.

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

Similar Threads

  1. Replies: 1
    Last Post: 11-18-2014, 12:35 PM
  2. Replies: 3
    Last Post: 02-25-2014, 11:46 AM
  3. Replies: 1
    Last Post: 07-10-2013, 08:57 AM
  4. Multiple default values in listbox
    By rickscr in forum Forms
    Replies: 3
    Last Post: 04-07-2011, 09:49 AM
  5. On Load, form not visible
    By Bruce in forum Forms
    Replies: 15
    Last Post: 02-24-2010, 04:06 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