Link to home
Start Free TrialLog in
Avatar of DoughBoy
DoughBoy

asked on

OLE from VB5 to Access97

Here is my code:

    Dim objAccess As Access.Application
    Set objAccess = New Access.Application
    objAccess.OpenCurrentDatabase DBName
    objAccess.Application.Visible = True

It starts Access from VB.  Access flashes for a second or two and then disappears.  How do I keep Access97 Open and viewable until I desire otherwise?

Thanks in Advance,
DoughBoy
ASKER CERTIFIED SOLUTION
Avatar of jeffcameron
jeffcameron

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DoughBoy
DoughBoy

ASKER

Thanks Jeff,  your suggestion worked.  You can receive full credit.  
Can I ask you a follow up question?  I should have made the requirement that Microsoft Access Library 8.0 can not be referenced by VB IDE.  Now how do I open Access to a specific DB and keep it open until I feel like closing it?

Thanks for your help,
DoughBoy
' you must declare your variable globally so
' it stays in memory once access becomes dereferenced
' it closes
Private Access as object


Private Sub OpenDatabase( Filename as string )
Set Access = CreateObject("Access.Application")

Access.OpenCurrentDatabase Filename
Access.Visible = True

End Sub
Thanks so much.  It worked.  What references have/do you use to learn VB?  Your help has been much appreciated.
I have learned it all from either the help files or the Internet, I have never bought a book or a magazine and have never taken a class.  I have been actively using VB for 5+ years and have put a lot of time into learning COM technologies(it is how you are opening Access).  I have found that the more you learn the faster you learn, because you figure out how to get the information you wan't more quickly (an exponential learning curve).  So just stick with it, it will get easier and easier.  
I don't know your application but if you are very interested in using VB with Access as a database, you should investigate DAO if you are using VB 5.0 or ADO if using VB 6.0.  However it sounds like you want to take advantage of the Access itself and not just Access as a database.  Just a bit of advice.  Jeff      
Thanks.  I appreciate the reply.
Thanks.  I appreciate the reply.