Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Location
    Iowa
    Posts
    7

    Unanswered: Calling a Record ID from a Subform for Controlling a Listbox

    I want a simple Listbox to display only the Cabinet records where the RecordID of the Cabinet Record matches the RecordID of the Space Subform. Because I'm on a subform, the usual syntax does not appear to be working (eg. [Forms]![SiteFrm]![SpacesFrm]![CabinetID]. I usually place this type of argument in the 'Criteria' Row of the Query that is the Listbox Record Source, but since it's on a Subform and not on the main form, it's not working. HELP!!

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    This is sort of a round about way of doing it, but you could programmatically add each value.

    Here's a bit of modified code I use to programmatically add values to list boxes:

    first you have to clear the list box:

    If lbList.ListCount > 0 Then
    Do Until lbList.ListCount = 0
    lbList.RemoveItem (0)
    Loop

    Then you assign values to the list box:

    Dim FrmMain As Form
    Dim FrmSub As Form
    Dim i As integer

    Set FrmMain = Forms!yourmainform
    Set FrmSub = Forms!yoursubform

    For i = 0 to frmSub.recordcount - 1
    FrmMain!lbYourlist.AddItem FrmSub.Recordset.Fields(enterfieldindex)
    FrmSub.Recordset.MoveNext
    next i

    **I'll see if I can come up with a bit more elegant solution, but I don't have much time to think it through just at the moment. That's just a quick fix.

    Last edited by Teddy; 11-06-03 at 13:22.

  3. #3
    Join Date
    Oct 2003
    Location
    Iowa
    Posts
    7
    Hey Teddy,

    Thanks so much for responding to my question. I got a little help from a co-worker who reminded me that I just needed to Requery the List Boxes. My Argument was actually doing it's job. I'm such a numskull sometimes. Just a wannabe.

    I will keep your code example for future tasks. It is much advanced of my capability. Thanks again!! Jim (Revixx)

    _________________________________________________

    [QUOTE][SIZE=1]Originally posted by Teddy
    This is sort of a round about way of doing it, but you could programmatically add each value.

Posting Permissions

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