2 Replies - 565 Views - Last Post: 19 March 2012 - 11:37 AM Rate Topic: ***** 1 Votes

#1 vasanth0611  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 16-March 12

I dunno what to do how to get ms access values in combobox in vb6.0?

Posted 16 March 2012 - 11:48 PM

'Dim cnview As New ADODB.Connection
'Dim rsview As New ADODB.Recordset
'Call Connection(cnview, App.Path & "\additem.mdb", "")
'Call Recordset(rsview, cnview, "SELECT itemno FROM additems")
'With rsview
'While Not .EOF
'Combo1.additem .Fields!agreeitemno.MoveNext
'Wend
'End With
'Set cnview = Nothing
'Set rsview = Nothing
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
'Set con = New ADODB.Connection
'Set rs = New ADODB.Recordset
Set con = DBEngine.OpenDatabase("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=database\additem.mdb;Persist Security Info=False")
Set rs = con.OpenRecordset("additems ")
'Set conn = DBEngine.OpenDatabase(App.Path & "\additem.mdb")
'Set rs = conn.OpenRecordset("additems")

If rs.RecordCount > 0 Then
Do While Not rs.EOF
With Combo1
.additem rs.Fields("itemno")
End With
rs.MoveNext
Loop
End If

Is This A Good Question/Topic? 0
  • +

Replies To: I dunno what to do how to get ms access values in combobox in vb6.0?

#2 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 271
  • View blog
  • Posts: 1,633
  • Joined: 26-March 09

Re: I dunno what to do how to get ms access values in combobox in vb6.0?

Posted 17 March 2012 - 12:01 AM

Please can you edit your post and put the code in the [ CODE] tags as it makes it much easier to read.

Can you tell us what the program does/doesn't do at the moment?

Is the DB part working OK, I would suspect not, as you have some of the variables commented out that you're trying to use, so I suspect you get an error?

Have a look at this link on Access DB connectivity using ADO. It's quite indepth and covers both DAO, ADO Controls and ADO programming.
Was This Post Helpful? 0
  • +
  • -

#3 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 547
  • View blog
  • Posts: 2,904
  • Joined: 19-May 09

Re: I dunno what to do how to get ms access values in combobox in vb6.0?

Posted 19 March 2012 - 11:37 AM

Given that ADODB doesn't have an OpenRecordset method, I'd say your suspicion is a valid one, maj. vasanth, you have mixed up DAO and ADO stuff. It's a common problem. They aren't interchangeable. I recommend using ADO rather than DAO. Follow the link that maj provides, and you should be able to get sorted pretty quickly.

This post has been edited by BobRodes: 19 March 2012 - 11:40 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1