Solved

Compiling ACCESS in a VB application

Posted on 1998-12-10
4
167 Views
Last Modified: 2010-05-03
Is there any possiblity to insert an access DB to a VB application, and generate an exe file, that will run on computers that have no MS-ACCESS installed? What is the best way to use the DB in the VB application?
0
Comment
Question by:schler
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
jjbyers earned 100 total points
Comment Utility
You can't compile the MDB file as part of the application.

But you can include the MDB file in your setup program. Using the setup wizard just add it to the list of files needed.


0
 
LVL 12

Expert Comment

by:mark2150
Comment Utility
You can even have your VB program create a .MDB on the fly. Access is *NOT* required on the target system. Here's some code:

Text1(2).Text is a control that has the drive:\path\ of the MDB file, REFMDB has the file name with the .MDB extension

db is PUBLIC ... AS DATABASE

'
' Crank up data engine to create database
'
Set db = DBEngine.Workspaces(0).CreateDatabase(Text1(2).Text & "\" & refmdb, dbLangGeneral)
Set tbl = db.CreateTableDef("Results")  'Configuration
'
' Filename - C20
' DiskVol  - C11
' Pagenum  - N3
' DateTime - Date/Time
' Client   - N6
' Debtor   - N6
'
Set fld = tbl.CreateField("Filename", dbText, 20)
fld.AllowZeroLength = True
tbl.Fields.Append fld
'
Set fld = tbl.CreateField("DiskVol", dbText, 11)
fld.AllowZeroLength = True
tbl.Fields.Append fld
'
Set fld = tbl.CreateField("Pagenum", dbInteger)
tbl.Fields.Append fld
'
Set fld = tbl.CreateField("DateTime", dbDate)
tbl.Fields.Append fld
'
Set fld = tbl.CreateField("Client", dbLong)
tbl.Fields.Append fld
'
Set fld = tbl.CreateField("Debtor", dbLong)
tbl.Fields.Append fld
'
Set ndx = tbl.CreateIndex("Key")
ndx.Fields.Append ndx.CreateField("Client")
ndx.Fields.Append ndx.CreateField("Debtor")
ndx.Unique = False
tbl.Indexes.Append ndx
'
Set ndx = tbl.CreateIndex("Location")
ndx.Fields.Append ndx.CreateField("FileName")
ndx.Fields.Append ndx.CreateField("PageNum")
ndx.Unique = False
tbl.Indexes.Append ndx
'
' Commit definition to master dataset
'
db.TableDefs.Append tbl
db.Close

0
 
LVL 12

Expert Comment

by:mark2150
Comment Utility
P.S.

You *MUST* put a data control onto your form to let the compiler know to include the JET ISAM. I make the controls .Visible property = FALSE so it doesn't show. The control is *NOT* referenced anywhere in my code, but if you forget the empty control *NONE* of the code will work - very frustrating when I first had to figure *that* out.

M

0
 
LVL 3

Expert Comment

by:jjmartin
Comment Utility
They've got it right.  You don't include ACCESS with the VB application.  The database is independant of ACCESS.  An ACCESS Database is ODBC compliant, and is accessed by VB through the Jet DB.  If you want to work with databases with out putting a data control on your form, in the Project References, select the Microsoft DAO 3.5 object library.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now