Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2002
    Location
    Hamilton,Ontario
    Posts
    132

    Unanswered: Help popluating ComboBox from ADO

    Hi
    I have one combobox called Category and I have one comboBox called Item Number.
    If a user clicks on RIPPED from Category Combobox , I want Item Number combobox to be filled.
    tablename=Invenotry


    Here is the code , which works perfectly but only populates one value, but i want all the Item Numbers to be populated which has RiPPED Category.

    Private Sub Category_AfterUpdate()
    Dim curdb As Database
    Dim SQLStmt As String
    Dim adrs As Recordset
    Set curdb = CurrentDb()
    Dim cat As String
    If Me![Category].Value = "RIPPED" Then
    cat = Me![Category].Value
    SQLStmt = "Select Inventory.[Item Number] from [Inventory] where [Category]='" & cat & "'"
    Set adrs = curdb.OpenRecordset(SQLStmt, dbOpenDynaset)
    Do Until adrs.EOF
    Me![Item Number].value = adrs![Item Number]
    Loop
    adrs.Close
    End If
    If Me![Category].Value = "PLANNED" Then
    cat = Me![Category].Value
    SQLStmt = "Select Inventory.[Item Number] from [Inventory] where [Category]='" & cat & "'"
    Set adrs = curdb.OpenRecordset(SQLStmt, dbOpenDynaset)
    Do Until adrs.EOF
    'Shows one value only
    'crahses on me if i .value out
    Me![Item Number].value = adrs![Item Number]
    Loop
    adrs.Close
    End If
    End Sub



    any Help will be appreciated. Thank You in advance.

  2. #2
    Join Date
    Jun 2002
    Location
    Vienna, VA
    Posts
    53

    Cool Re: Help popluating ComboBox from ADO

    you need to advance the recordset.

    Do Until adrs.EOF
    Me![Item Number].value = adrs![Item Number]
    adrs.movenext
    Loop



    Leah


    Originally posted by VBAPROGRAMMER
    Hi
    I have one combobox called Category and I have one comboBox called Item Number.
    If a user clicks on RIPPED from Category Combobox , I want Item Number combobox to be filled.
    tablename=Invenotry


    Here is the code , which works perfectly but only populates one value, but i want all the Item Numbers to be populated which has RiPPED Category.

    Private Sub Category_AfterUpdate()
    Dim curdb As Database
    Dim SQLStmt As String
    Dim adrs As Recordset
    Set curdb = CurrentDb()
    Dim cat As String
    If Me![Category].Value = "RIPPED" Then
    cat = Me![Category].Value
    SQLStmt = "Select Inventory.[Item Number] from [Inventory] where [Category]='" & cat & "'"
    Set adrs = curdb.OpenRecordset(SQLStmt, dbOpenDynaset)
    Do Until adrs.EOF
    Me![Item Number].value = adrs![Item Number]
    Loop
    adrs.Close
    End If
    If Me![Category].Value = "PLANNED" Then
    cat = Me![Category].Value
    SQLStmt = "Select Inventory.[Item Number] from [Inventory] where [Category]='" & cat & "'"
    Set adrs = curdb.OpenRecordset(SQLStmt, dbOpenDynaset)
    Do Until adrs.EOF
    'Shows one value only
    'crahses on me if i .value out
    Me![Item Number].value = adrs![Item Number]
    Loop
    adrs.Close
    End If
    End Sub



    any Help will be appreciated. Thank You in advance.

Posting Permissions

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