MS Access to VB program (or Excel) using VB code

  Charence 00:35 26 Jun 2004


At the moment all I have managed is to open a database using Visual Basic code, but not extract data from it.

Could anybody please tell me what VB code I would need to open a database and place it in a program I have written?



  AccessMoron 13:07 26 Jun 2004

what version of access, VB or Excel are u using?

  Charence 19:16 26 Jun 2004

Access 2002, VB6, Excel 2002

Cheers, Charence

  Charence 23:38 26 Jun 2004

I have managed to open the database using VB but cannot extract data from it. Any ideas?

Here's the code that opens it

Dim db As Object

Private Sub Workbook_Open()

Set db=GetObject("database.mdb")



  Charence 12:37 29 Jun 2004

any ideas anybody?


  Charence 18:22 29 Jun 2004

Question Rephrased


What Visual Basic Code would I need to write in order to view data in tables within Access Database?



  VoG II 18:26 29 Jun 2004

Does click here help?

  AccessMoron 23:36 03 Jul 2004

put the microsoft ADO data control onto the form, right click its properties (this will get u the connection string)

then in the code window you need the following

code that follows has not been tested. nut its somewhere pretty close.

dim DB as adodb.database
dim RS as adodb.recordset

set db = new adodb.database
db.connectionstring = {get this from the ado control}

set rs = new adodb.recordset
rs.activeconnection = db {SQL string}

if not rs.eof and not rs.bof then
msgbox rs.fields("myFieldName").value
end if

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

Samsung Galaxy A8 review: Hands-on

Illustrator Juan Esteban Rodriguez on creating highly detailed official film posters for Star Wars…

iMac Pro review

Quelle est la meilleure application de podcast pour Android (2018) ?