Click to See Complete Forum and Search --> : datacombo, filling
frank ashley
May 4th, 2000, 03:14 PM
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
Sajid
Aug 22nd, 2001, 02:10 AM
Hi Frank
I am also having the same problem if you have found the problem then please forward to me also.
bye
sajid
BrandonSk
Aug 22nd, 2001, 05:10 AM
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!
BrandonSk
Aug 22nd, 2001, 05:13 AM
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.
zeke_wpg
Aug 22nd, 2001, 04:14 PM
Is this a People Soft thing?
:confused:
zeke_wpg
Aug 22nd, 2001, 04:48 PM
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..
Edneeis
Aug 22nd, 2001, 06:08 PM
It looks like it didn't work because you of the cursor type:
Try this:
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", adOpenKeyset, adLockOptimistic
Set DataCombo1.RowSource = myrs
DataCombo1.ListField = "name"
End Sub
zta
Sep 15th, 2002, 08:34 AM
check out this page for the right fields to use: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q189682&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
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.