?
Solved

OLE from VB5 to Access97

Posted on 1998-12-16
7
Medium Priority
?
260 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
[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
  • 4
  • 3
7 Comments
 
LVL 1

Accepted Solution

by:
jeffcameron earned 200 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
Industry Leaders: 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!

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
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…

765 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