Results 1 to 5 of 5

Thread: Extracting field data when a Record is selected

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Posts
    82
    Here's a simple, down and dirty solution.

    When you create your form, add a 2nd combo box, set visible=false and populate it with the field data you want at the same time you populate your actual combo box. Then, in the actual combo box's click event, do this:
    cboDummy.ListIndex = cboActual.ListIndex

    Your dummy combo box will always hold the field data you want.

  2. #2
    Addicted Member Pickler's Avatar
    Join Date
    May 2001
    Location
    nffanb
    Posts
    248
    Another way you can do this is to use the ItemData property of the list box.

    VB Code:
    1. With Combo1
    2.  .Additem rs!Field1
    3.  .ItemData(.NewIndex)=rs!Field2
    4. End With
    5.  
    6. 'Then when you select an entry
    7. Label1=Combo1.ItemData(Combo1.ListIndex)


  3. #3
    Junior Member
    Join Date
    Jan 2002
    Location
    Chicago
    Posts
    26
    Private Sub Combo3_Change()
    With Combo3
    .Additem rs!Field1
    .ItemData(.NewIndex) = rs!Field2
    End With

    'Then when you select an entry
    Label35 = Combo3.ItemData(Combo3.ListIndex)

    End Sub

  4. #4
    Junior Member
    Join Date
    Jan 2002
    Location
    Chicago
    Posts
    26
    Private Sub Combo3_Change()
    Dim db As Database
    Dim rs As Recordset
    Set db = OpenDatabase("c:\windows\desktop\Visual Basic Projects\Bst_Drawing.mdb")
    Set rs = db.OpenRecordset("SELECT * " & _
    "FROM Document_Type ")

    'Label35.Caption = rs = abreviation
    With Combo3
    .Additem rs!Field1
    .ItemData(.NewIndex) = rs!Field2
    End With

    'Then when you select an entry
    Label35 = Combo3.ItemData(Combo3.ListIndex)
    End Sub




    I'm getting a method or data member not found error for the ".AddItem"

    Which Field is the one from the combo box and which one is the data I'm trying to extract?

  5. #5
    Junior Member
    Join Date
    Jan 2002
    Location
    Chicago
    Posts
    26
    Private Sub Combo3_Change()
    'Dim db As Database
    'Dim rs As Recordset
    'Set db = OpenDatabase("c:\windows\desktop\Visual Basic Projects\Bst_Drawing.mdb")
    'Set rs = db.OpenRecordset("SELECT * " & _
    "FROM Document_Type ")

    'Label35.Caption = rs = abreviation
    With Combo3
    .Additem rs!Abbreviation
    .ItemData(.NewIndex) = rs!Document_Type
    End With

    'Then when you select an entry
    Label35 = Combo3.ItemData(Combo3.ListIndex)
    End Sub

    This particular bit of code removes the list I am choosing from and call up a dialog box that requests the "Document_type.Document_Type"

Posting Permissions

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



Click Here to Expand Forum to Full Width