Results 1 to 8 of 8

Thread: datacombo, filling

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    London
    Posts
    99

    Angry

    I can fill a datacombo at design time using adodc but not at runtime using the code below. The recordset has records in (i've checked using the immediate pane), but no records are displayed in the datacombo itself.

    Option Explicit

    Private Sub Form_Click()
    Dim myrs As ADODB.Recordset
    Set myrs = New ADODB.Recordset

    myrs.Open "Select * from career_officers", _
    "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=CSRSRep;Data Source=DEVSRV1"

    Set DataCombo1.RowSource = myrs
    DataCombo1.ListField = "name"

    End Sub

  2. #2
    Sajid
    Guest
    Hi Frank

    I am also having the same problem if you have found the problem then please forward to me also.

    bye
    sajid

  3. #3
    Addicted Member
    Join Date
    Aug 2000
    Posts
    195
    Hi guys. Seems like the ADO ain't that great, huh? Well, I am sure it is after you really find out how to use it. I had similar problems with datacombo a year ago and never really solved it. So I think this will not help you but ... you never know.
    So in the project I was working on I had a ADOdatacombo that displayed values (let's say names). On the same form there was an option to add a new name. It was added into the database and NOW, believe I tried everything from a simple combo requery or refresh, changing datasource (SQL) all the means of refreshing the Data environmenet and guess what ... the new record wasn't there. Suprisingly enough it appeared but AFTER I UNLOADED AND THEN RELOADED the entire form again -> so what do you think? I have no idea because I see no links between un/loading the form and DataEnv.
    Anyway if you are wondering how I solved it afterwards /nobody here could help me / it was quite simple -> forgot about ADO and all the "simple and unified ways of accessing datas" and switched back to DAO. Little more code, maybe little slower but more than that - IT WORKED!
    Brandon

  4. #4
    Addicted Member
    Join Date
    Aug 2000
    Posts
    195
    Just to make myself clear -> by saying the record wasn't there I mean it's been added to database and was in the table but no-way to get him to the combo.
    Brandon

  5. #5
    New Member
    Join Date
    Aug 2001
    Location
    Winnipeg
    Posts
    10
    Is this a People Soft thing?

  6. #6
    New Member
    Join Date
    Aug 2001
    Location
    Winnipeg
    Posts
    10

    Unhappy

    First of all, why NOT use the ADODC ? The combo could still be refreshed as you wanted.. I'm sure you can populate the DataCOmbo progmatically. but i've not been able to figure it out myself( quell suprise!). Also, why not use a regular combo and just populate it with your recordset? Alternatively, create an active x control..

  7. #7
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    It looks like it didn't work because you of the cursor type:
    Try this:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Click()
    4. Dim myrs As ADODB.Recordset
    5. Set myrs = New ADODB.Recordset
    6.  
    7. myrs.Open "Select * from career_officers", _
    8. "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=CSRSRep;Data Source=DEVSRV1", adOpenKeyset, adLockOptimistic
    9.  
    10.  
    11. Set DataCombo1.RowSource = myrs
    12. DataCombo1.ListField = "name"
    13.  
    14. End Sub

  8. #8
    New Member
    Join Date
    Aug 2001
    Posts
    8

    Wink filling datacombo boxes

    check out this page for the right fields to use: http://support.microsoft.com/default...9682&ID=189682

    I noticed that the combo box fills only if using a static curser, not a dynamic cursor (on the MSDE engine any way!)

    for example, generate the recordset like this:
    rsPtStatus.Open SQL, conDB, adOpenStatic

    not like this...
    rsPtStatus.Open SQL, conDB, adOpenDynamic

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