Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

Using VB with an Access database

Posted on 1998-09-27
10
Medium Priority
?
386 Views
Last Modified: 2008-03-10
I am in he middle of writing a fun little program for our hockey team where we can enter the results from our games and the goal scorers etc.  I want to store the data in an Access table but am having trouble setting up the connection.  Here is what I thought I had to use:
Set oldws = DBEngine.Workspaces(0)
Set olddb = oldws.OpenDatabase(Path + "hurricanes.mdb")
Set newdyn = olddb.OpenRecordset("Select * from individual", dbOpenDynaset)
I also have these in a module:
Public olddb As Database
Public oldws As Workspace
Public newdyn As Recordset
For some reason it stops st the set statements, can anyone help me?
0
Comment
Question by:treyjeff
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 12

Expert Comment

by:mark2150
ID: 1436874
Which statement does it stop at?

This is what I use:

Set db = DBEngine.Workspaces(0).OpenDatabase(DataDir)
Set tbl = db.OpenRecordset("config")

Since I want all records/fields I don't have to use a SELECT, I just open the table and go.

I never close the db object until the program exits. Tables I open and close on demand, but the reset I let stand.

M


0
 
LVL 1

Expert Comment

by:toys032498
ID: 1436875
Did you reference the Microsoft DAO 3.5 Object Library before you begin coding?
If so this is all you have to write for accessing an Access Database.

Private Sub Form_Load()

' Create dynaset-type recordsets

Dim db as Database 'The dynaset object
Dim rs as Recordset 'The recordset object

'  Create local variables
Dim strDBname as string
Dim strRSname as string

'  Initialize the variables
strDBname = App.Path & "c:\hurricanes.mdb"
strRSname = "tblName here"

' Create the objects
Set db = DBEngine.OpenDatabase(strDBname)
Set rs = db.OpenRecordset(strRSname, dbOpenDynaset)

End Sub


If you really want to make it easy, why not use ADO?
Good luck,
Anthony
0
 
LVL 1

Author Comment

by:treyjeff
ID: 1436876
What is ADO, I'm using VB 5.0 Pro by the way and Access 95.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 1

Author Comment

by:treyjeff
ID: 1436877
I got an error on the following line:
Set db = DBEngine.Workspaces(0).OpenDatabase(DataDir)
It said unable to open the DLL.
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1436878
treyjeff:
Can you state the exact error message.
"unable to open the DLL" is not found in the error list.
0
 
LVL 1

Author Comment

by:treyjeff
ID: 1436879
Run time error 48
Error in loading DLL
0
 
LVL 2

Expert Comment

by:shogi
ID: 1436880
Check in you reference, do you have the right DAO?

Go in "Project" -> "references"
Selecte "Microsoft DAO 3.5 Object library"

if it's selected you receive again this message : it's because you don't have any more this DLL on you system or your DLL it's not registred in the registry.

Regards,
Shogi
0
 
LVL 1

Accepted Solution

by:
toys032498 earned 120 total points
ID: 1436881
ADO is ActiveX Data Object, very similar to DAO and RDO
You can download ADO 1.5 from Microsoft as a release version,  VB6.0 has the lastest version 2.0.  Check it out! Its awsome stuff!

Dont forget to Reference you DAO Object like I told ya or you will get the .dll Error.  VB is looking for the refernce to DAO Object and cant find it cause it doesnt exist in your application unil you reference it.
Anthony
0
 
LVL 1

Author Comment

by:treyjeff
ID: 1436882
Thanks, i had it referenced all along but I also had a reference to Access and it must have been conflicting.
0
 
LVL 1

Expert Comment

by:toys032498
ID: 1436883
Thanks for the points!
Yeh! That will cause your error.
Good Luck on your Hockey Team Wins. Go Hurricanes....and George too!  Hehehe!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

647 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