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

  Charence 00:35 26 Jun 04
Locked

Hi,

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?

Thanks

Charence

  AccessMoron 13:07 26 Jun 04

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

  Charence 19:16 26 Jun 04

Access 2002, VB6, Excel 2002

Cheers, Charence

  Charence 23:38 26 Jun 04

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")

******

Thanks

  Charence 12:37 29 Jun 04

any ideas anybody?

Thanks

  Charence 18:22 29 Jun 04

Question Rephrased

**************************************

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

**************************************

Thanks

  VoG II 18:26 29 Jun 04

Does click here help?

  AccessMoron 23:36 03 Jul 04

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}
db.open

set rs = new adodb.recordset
rs.activeconnection = db
rs.open {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.

Best phone camera 2016/2017: Galaxy S7 vs iPhone 7 vs Google Pixel vs HTC 10 Evo vs OnePlus 3T vs…

1995-2015: How technology has changed the world in 20 years

The Pantone Colour of the Year 2017 is Green

Super Mario Run preview | Hands-on first impressions of Super Mario Run: Mario's iPhone & iPad…