Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to open an Access2000 database in my VB6 project?

Status
Not open for further replies.

ljvb7

Programmer
May 18, 2001
7
US
I need to create a command button in my VB6 project which will open a particular Access2000 database up in form view.
I thought I could use the OLE Control from the toolbox, however, it does not offer Access as an option. I tried to add it as a component, but couldn't select it.
Anyone ever done this, is it a problem? Know how to?
 
I use this code (and it works):

1. In a module I declare:

Public PathStock as String 'so it is available in the entire project



2. Then in a the first start form event: Form_Load() subroutine I have:

Dim strConn as String
Dim cnStcok as ADODB.Connection

PathStock = "\\DE-FP-SERVER\E DRIVE\Vincent\Stock.mdb"

strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & PathStock & ";Jet OLEDB:Database Password=cel;"
Set cnStock = New ADODB.Connection 'define connection with database Stock
cnStockbeheer.Open strConn 'open the connection with database Stock

3. Then when opening another form, I declare use connection in order to display the contents of a table (here Planning):

Dim dbsStock As Database
Dim rstPlanning As Recordset

'define recordset from Planning table:
Set dbsStock = OpenDatabase(PathStock)
Set rstPlanning = dbsStockbeheer.OpenRecordset("Planning", dbOpenTable)

Please let me know if useful at
vincent.mairiaux@yucom.be

Vincent from Antwerp/Belgium
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top