Solved

Compiling ACCESS in a VB application

Posted on 1998-12-10
4
169 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
ID: 1449232
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
ID: 1449233
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
ID: 1449234
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
ID: 1449235
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

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