Solved

OLE from VB5 to Access97

Posted on 1998-12-16
7
248 Views
Last Modified: 2013-11-25
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
0
Comment
Question by:DoughBoy
  • 4
  • 3
7 Comments
 
LVL 1

Accepted Solution

by:
jeffcameron earned 50 total points
ID: 1450800
you don't have to create the access variable it is already global and is called Access.  The code you need is below

Access.OpenCurrentDatabase  DBFileName
Access.Visible = True

AppActivate "Microsoft Access"
0
 

Author Comment

by:DoughBoy
ID: 1450801
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
0
 
LVL 1

Expert Comment

by:jeffcameron
ID: 1450802
' 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
0
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.

 

Author Comment

by:DoughBoy
ID: 1450803
Thanks so much.  It worked.  What references have/do you use to learn VB?  Your help has been much appreciated.
0
 
LVL 1

Expert Comment

by:jeffcameron
ID: 1450804
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      
0
 

Author Comment

by:DoughBoy
ID: 1450805
Thanks.  I appreciate the reply.
0
 

Author Comment

by:DoughBoy
ID: 1450806
Thanks.  I appreciate the reply.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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 …
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…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

705 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

22 Experts available now in Live!

Get 1:1 Help Now