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!

VB and Microsoft Access

Status
Not open for further replies.

Learning123

Programmer
May 12, 2002
29
US
Hi Everyone,
Just a quick question. I'm clueless in Access, but was asked to create a VB program to trigger a macro called "VB_Launch" inside a Microsoft Access Database (2000) located in C:\MyData.mdb. Anyone has any ideas how this is done, I've managed to reference the Access object Library 9.0. But got lost in openning the database and running the macro. Any help or suggestions a greatly appreciated! And as always thank you for your time!

Andy
 
Hi,
I can only help with the first part... I too am looking for a way to fire a macro.

To open the database (the easiest way I've found in VB6), add the Microsoft DAO Library (in your "references" list, my current version is 3.6) and add the following code:

Code:
dim db as database
set db = opendatabase("pathname")
... (your code here)
db.close
[\code]

As I said, I am also looking for a way to fire the macro once the database is open... can anyone provide that answer?

Ben
 
Try the following:

Set a reference in your VB app to the Microsoft Access Object Library (I'm on version 10.0 - must be for Access 2000). Call your macro like this:

Private Sub Command1_Click()
Dim mdb As Access.Application

Set mdb = New Access.Application
mdb.OpenCurrentDatabase "c:\myaccess.mdb", False
mdb.DoCmd.RunMacro "MyMacro"
End Sub

I tried it, and it seems to work just fine.
 
Thanks everyone, It works! problem solved! Man, You guys are good!!! Thanks again!
 
Hey, LlomaxX...

I've got Access 2k and my highest library is 9.0; for some reason, I can't get that to work. Any ideas?
 
benlinkknilneb,

Don't know why you only have 9.0...maybe it is part of the latest MDAC, not Access. I am on MDAC 2.6 You can go here to get the latest and see if that works:


Otherwise, let me know what error you are getting and at what point, and I'll see if I can offer better advise.
 
Hey...did I get a vote cause it worked?!?!? I'm new, and it would be cool to get a vote so soon!


(Well, it worked for one person, anyway...) :)
 
LlomaxX
It's not normally considered good manners to solicit votes. You may find that as a newbie you won't be REDFLAGGED this time! Let me know if this helps
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top