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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does MS Access Exist? 1

Status
Not open for further replies.

brews

Technical User
Dec 12, 2007
194
US
In VB6 I checked to see if the user had MS Access installed before checking for a table. This procedure is to make sure the app does not crash because lack of the program Access. this code in VB6
Code:
Public Sub FindAccessVer(ByRef bFound As Boolean)
    Dim oXLApp As Object
    Dim sAppName As String
    sAppName = "Access.Application"
    Set oXLApp = OpenApp(sAppName, bFound)
    If Not bFound Then Exit Sub
    oXLApp.Quit
    Set oXLApp = Nothing
End Sub
This line
Code:
Set oXLApp = OpenApp(sAppName, bFound)
is causing initial problems. Is there a work around in .net?

Thanks.
 
Perhaps if you showed the contents of the OpenApp function it would help
 
Thanks for the response. Here is the code.
Code:
Function OpenApp(ByVal sAppName As String, ByRef bSuccess As Boolean) As Object
    Dim oApp As Object
    On Error Resume Next
    Set oApp = CreateObject(sAppName)
    If Err.Number = 0 Then
        Set OpenApp = oApp
        bSuccess = True
    Else
        bSuccess = False
    End If
    Set oApp = Nothing
End Function
 
It must have been the brews last night because the app is working as it is intended. Many thanx for the consideration.
 



You have much more going on than is necessary.

If OpenApp returns Nothing then no object was created...
Code:
Function OpenApp(ByVal sAppName As String) As Object
    Set OpenApp = CreateObject(sAppName)
End Function
So the call
Code:
   if OpenApp(YourApplicationName) is nothing then
       'no application object created
   else
       'application object created
   end if


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 


Well you probably do need the On error statement.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thank you. Sometimes the learning curve is steep but the experience is always worthwhile.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top