Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

VB6 noob - ref record set from DataCombo

Options
  • 16-04-2007 5:33pm
    #1
    Registered Users Posts: 307 ✭✭


    have just started vb6 really.
    I have a dataCombo control linked (ADO) to my access db in dropdown list style.
    The List populates alright (after some tinkerin) but I cant seem to get right the code for readiing in the rest of the data from the record selected by the list.

    Have been using various permutations of:
    Set Setup_ID = adoSetup.Recordset("ID")
    Set Setup_serial = adoSetup.Recordset("serial")
    .
    .
    
    or
    Setup_ID = adoSetup.Recordset.Fields("ID").Value
    Setup_serial_ID = adoSetup.Recordset.Fields("serial").Value
    .
    .
    
    etc.

    But to no avail.

    anyone with any suggestions much appreciated. Thanks :D


Comments

  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Post all your code, it's hard to understand what you're trying to achieve exactly.


  • Registered Users Posts: 307 ✭✭wolf99


    sorry, yup, but thats pretty much it

    the combo is populated by its property settings
    Sub SELECT_Click()
    
    Set String1 = adoTable.Recordset("FieldName1") 
    Set String2 = adoTable.Recordset("FieldName2")
    
    End Sub
    

    so that when the select button is clicked, whatever text has been selected in the combo is used to identify the record (i.e. recordset) - I thought this should be automatic, but maybe not?- so that other fields from that record may be read/written.

    sorry if its not too clear still, I'm not sure If I'm even asking the right Q here, If you know of a good tutroial site for this area let me know (most of the ones I looked at so far are not so good)

    Thank you :D


  • Registered Users Posts: 695 ✭✭✭DaSilva


    Depending on the whole project the method i used recently for a college project might be fine or not.

    If the data that is in the combo box is unique, then you can just use the Find method.

    IE. the combo box displays car registration numbers from a database of cars, no two cars have the same reg so that field is unique. When a user selects a reg from the combo box, the rest of the details are displayed in labels or something. what my code did was search for that field, not the nicest method but i used it because i had the same problem.
    Private Sub cmbCar_Click()
    adoCar.Refresh
    
    'find the record in the table with a reg that equals the combobox text
    adoCar.Recordset.Find "[RegNumber] = '" & cmbCar.Text & "'"
    
    'display record information in labels
    lblEngineSize.Caption = adoCar.Recordset![EngineSize]
    lblDoors.Caption = adoCar.Recordset![Doors]
    lblModel.Caption = adoCar.Recordset![Model]
    lblManufacturer.Caption = adoCar.Recordset![Manufacturer]
    lblMileage.Caption = adoCar.Recordset![Mileage]
    End Sub
    

    ps. Barry? :P


Advertisement