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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

VB6 noob - ref record set from DataCombo

  • 16-04-2007 4:33pm
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


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


  • Registered Users, Registered Users 2 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, Registered Users 2 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