14 Replies - 2183 Views - Last Post: 29 September 2011 - 09:38 AM Rate Topic: -----

#1 haidar976  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 12-August 11

What is the difference between datacombo and combo in vb6 ?

Posted 16 September 2011 - 06:19 AM

I am sure there are many differences between datacombo and combo but I don't know what is it?? please tell me if you know.
Is This A Good Question/Topic? 0
  • +

Replies To: What is the difference between datacombo and combo in vb6 ?

#2 Ionut  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 385
  • View blog
  • Posts: 1,057
  • Joined: 17-July 10

Re: What is the difference between datacombo and combo in vb6 ?

Posted 16 September 2011 - 01:56 PM

This may answer to your question
Was This Post Helpful? 1
  • +
  • -

#3 haidar976  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 12-August 11

Re: What is the difference between datacombo and combo in vb6 ?

Posted 17 September 2011 - 10:00 PM

Thank you
Was This Post Helpful? 0
  • +
  • -

#4 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: What is the difference between datacombo and combo in vb6 ?

Posted 17 September 2011 - 10:50 PM

The difference is that DataCombo can be directly bound to a data source and ComboBox can't. You can still do the binding with a ComboBox "by hand" using code.
Was This Post Helpful? 0
  • +
  • -

#5 haidar976  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 12-August 11

Re: What is the difference between datacombo and combo in vb6 ?

Posted 19 September 2011 - 02:25 AM

View PostBobRodes, on 18 September 2011 - 08:50 AM, said:

The difference is that DataCombo can be directly bound to a data source and ComboBox can't. You can still do the binding with a ComboBox "by hand" using code.


well, my database is Mydb.mdb, and data-source is mainTbl which is contains 2 columns ID and Tel-No, I want the combo box (Not DataCombo) to be filled by Tel-No can you write the code for this combo?
forgive me may I look lazy but I don't know how to find the correct codes from the references.

This post has been edited by haidar976: 19 September 2011 - 02:30 AM

Was This Post Helpful? 0
  • +
  • -

#6 Ionut  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 385
  • View blog
  • Posts: 1,057
  • Joined: 17-July 10

Re: What is the difference between datacombo and combo in vb6 ?

Posted 19 September 2011 - 03:33 AM

well, use a RecordSet to fetch data from database, then loop through it and add each record to your combobox.
do while not rs.EOF
.   combobox1.additem rs.fields(0)
.   rs.movenext
Loop



The code may have misspellings, but you got the idea

This post has been edited by Ionut: 19 September 2011 - 03:34 AM

Was This Post Helpful? 0
  • +
  • -

#7 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: What is the difference between datacombo and combo in vb6 ?

Posted 19 September 2011 - 12:57 PM

Yes, I can. I'd like you to be able to as well. So, do what you can, and ask for help when you need it.
Was This Post Helpful? 0
  • +
  • -

#8 haidar976  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 12-August 11

Re: What is the difference between datacombo and combo in vb6 ?

Posted 20 September 2011 - 12:07 AM

View PostIonut, on 19 September 2011 - 01:33 PM, said:

well, use a RecordSet to fetch data from database, then loop through it and add each record to your combobox.
do while not rs.EOF
.   combobox1.additem rs.fields(0)
.   rs.movenext
Loop



The code may have misspellings, but you got the idea


I have Adodc2 which connect to the mydb.mdb and the table name is (office)
i wrote this code
Dim rs As Recordset
rs = Adodc2.Recordset
combo2.AddItem rs.Fields(0)
rs.MoveNext
Loop


and I wrote this in the Private Sub Form_Load()
but I got this error
Compile error
Invalid use of property
where is my mistake?
Was This Post Helpful? 0
  • +
  • -

#9 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: What is the difference between datacombo and combo in vb6 ?

Posted 20 September 2011 - 04:27 PM

what line causes the error? Also, read up on do loops. You're missing a Do.

This post has been edited by BobRodes: 20 September 2011 - 04:27 PM

Was This Post Helpful? 0
  • +
  • -

#10 haidar976  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 12-August 11

Re: What is the difference between datacombo and combo in vb6 ?

Posted 20 September 2011 - 10:29 PM

View PostBobRodes, on 21 September 2011 - 02:27 AM, said:

what line causes the error? Also, read up on do loops. You're missing a Do.

First i have to mention that I forgot to write the line of do while in the replay above, so the real code I did in my project is:
Dim rs As Recordset
rs = Adodc2.Recordset
Do While not rs.EOF
combo2.AddItem rs.Fields(0)
rs.MoveNext
Loop


the error line (in yellow color) is the first line in the class, which is:
Private Sub Form_Load()
Was This Post Helpful? 0
  • +
  • -

#11 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: What is the difference between datacombo and combo in vb6 ?

Posted 21 September 2011 - 03:48 PM

Oh. The code you've posted is in your Form_Load procedure? If so, try changing your Dim rs As Recordset to Dim rs as ADODB.Recordset.If that doesn't work, try moving the code to the Form_Activate procedure.
Was This Post Helpful? 0
  • +
  • -

#12 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,606
  • Joined: 17-April 07

Re: What is the difference between datacombo and combo in vb6 ?

Posted 21 September 2011 - 07:16 PM

yes, you need to use the set operator
set rs=adodc2.recordset


This post has been edited by thava: 21 September 2011 - 07:17 PM

Was This Post Helpful? 1
  • +
  • -

#13 haidar976  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 12-August 11

Re: What is the difference between datacombo and combo in vb6 ?

Posted 21 September 2011 - 10:34 PM

Thank you all, it works now, I use ( set )
set rs = adodc2.recordset



View PostBobRodes, on 18 September 2011 - 08:50 AM, said:

The difference is that DataCombo can be directly bound to a data source and ComboBox can't. You can still do the binding with a ComboBox "by hand" using code.


I also tried this way, but I got the same error
Was This Post Helpful? 0
  • +
  • -

#14 haidar976  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 12-August 11

Re: What is the difference between datacombo and combo in vb6 ?

Posted 22 September 2011 - 12:34 PM

View PostBobRodes, on 22 September 2011 - 01:48 AM, said:

Oh. The code you've posted is in your Form_Load procedure? If so, try changing your Dim rs As Recordset to Dim rs as ADODB.Recordset.If that doesn't work, try moving the code to the Form_Activate procedure.

I also tried this way, but the same error appear!
Any way i was tried to learn more ways and that was really helpful
thank you
Was This Post Helpful? 0
  • +
  • -

#15 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: What is the difference between datacombo and combo in vb6 ?

Posted 29 September 2011 - 09:38 AM

Oops. Forgot about the Set keyword. Good catch thava.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1