Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2008
    Posts
    9

    Unanswered: Trigger for list box element...?

    Hey everyone!

    I've got a little problem, I was wondering if you might be able to give me a hand...? So here it is:

    I've implemented a form which pops up on start-up. That has a list box which works as a basic list of any assignments due within the week. The only thing is what I want to do from there is be able to double-click an item on the list and go to the relevant record to see the full set of details, the list box only provides a brief summary. I'm having trouble specifying an event on a single element of a list box rather than the whole list box object itself. Clearly I'm approaching this entirely the wrong way. Any ideas?

    Any help would be greatly appreciated =D

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Presuming the listbox is single select, this technique should work:

    http://www.baldyweb.com/wherecondition.htm

    from the double click event of the listbox.
    Paul

  3. #3
    Join Date
    Nov 2008
    Posts
    9
    I don't follow what you mean by single select. The listbox has fours columns and a variable amount of records depending on the results of the query. One of those records are active or have focus at any one time.

    Thanks for the link btw. I gave it a go but it asks me for the assignmentID parameter when I double click. This is the procedure I've written:

    Private Sub lstOneWeek_Click()
    DoCmd.OpenForm "frmAssignment", acNormal, , "frmAssignment.assignmentID = " + Me.lstOneWeek, acFormReadOnly, acDialog
    End Sub

    Where:
    - frmAssignment is the form which contains a record with details for each individual assignment (the form I want to open)
    - assignmentID is the primary key of tblAssignment which frmAssignment and qryOneWeekLeft (the summary listbox's data source) is based on
    - lstOneWeek is the summary listbox (I want to double click one item from this list to initiate the opening of the form with full details)
    Last edited by sphynx; 12-15-08 at 00:53.

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    If it's set so you can only select one item at a time, it's single select. If you can select more than one, it's multi-select. Did you try the code?
    Paul

  5. #5
    Join Date
    Nov 2008
    Posts
    9
    Oh ok. Yes it is single select then.

    I tried the code but I must have done something incorrectly because as I said in the last post it asks me for frmAssignment.assignmentID when I click.

    Is there something wrong with the code I've put together? It's in the last post.

  6. #6
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    If you'll notice in the sample code provided, you should not include the form reference in the wherecondition. You specify the field name only. You should also use & instead of +.
    Paul

  7. #7
    Join Date
    Nov 2008
    Posts
    9
    OK I've made those changes. Same error though.

    It looks like this now if that helps:

    DoCmd.OpenForm "frmAssignment", acNormal, , "assignmentID = " & Me.lstOneWeek, acFormReadOnly, acDialog

  8. #8
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    What is the code now? Is assignmentID a field in the source of the form being opened?
    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •