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

How to find MSACCESS in registry....

Status
Not open for further replies.

netcert

Programmer
Apr 11, 2001
115
US
I have this code that looks for Access on the users PC on either C: or D: and then opens Access.

However, now I learn I can just change my code to open Access through the registry settings on the users PC but I don't know the command for that. I'm including my current code in hopes that someone can tell me how to modify it.

-----------------------------------

If Len(Dir("C:\Program Files\Microsoft Office97\Office\MSACCESS.EXE")) > 1
Then
bytDirAt = 5
ElseIf Len(Dir("C:\Program Files\Microsoft Office\Office\MSACCESS.EXE")) > 1
Then
bytDirAt = 2
ElseIf Len(Dir("c:\XPOffice\MSACCESS.EXE")) > 1 Then
bytDirAt = 4
ElseIf Len(Dir("D:\Program Files\Microsoft Office\Office\MSACCESS.EXE")) > 1
Then
bytDirAt = 3
Else
bytDirAt = 1
End If

runnit:
If Command <> &quot;&quot; Then
DB = Mid(Command, 5)
Else
DB = &quot;J:\gtllp\Access Databases\GT_ISA_REPORT.mdb&quot; & Chr$(34) & &quot; /X
OnOpen&quot;
End If

Select Case bytDirAt
Case 1
strfilename = &quot;d:\Office97\Office\MsAccess.exe &quot; & Chr$(34) & DB
Case 2
strfilename = &quot;C:\Program Files\Microsoft Office\Office\MSACCESS.EXE
&quot; & Chr$(34) & DB
Case 3
strfilename = &quot;D:\Program Files\Microsoft Office\Office\MSACCESS.EXE
&quot; & Chr$(34) & DB
Case 4
strfilename = &quot;C:\XPOffice\MsAccess.exe &quot; &
Chr$(34) & DB
Case 5
strfilename = &quot;C:\Program Files\Microsoft
Office97\Office\MSACCESS.EXE &quot; & Chr$(34) & DB
End Select

runner = Shell(strfilename, vbMaximizedFocus)
Exit Sub
errHandle:
If Err = 52 Then
bytDirAt = 2
Resume runnit
End If
MsgBox &quot;whoops&quot; & vbCrLf & Err.Number & &quot;: &quot; & Err.Description
End Sub


-------------------------------------

Thanks.

Rob
 
By the looks of the code (and I admit I've not looked closely, so correct me if I'm wrong) you are trying to open a database file from code.
Copy the code from my FAQ:faq705-1971 into a module then call it with
call fHandleFile(DB,WIN_MAX) and that will open the file in whatever Access file is present on the database. It also works with any other type of file.

HTH

Ben ----------------------------------------
Ben O'Hara
Home: bpo@SickOfSpam.RobotParade.co.uk
Work: bo104@SickOfSpam.westyorkshire.pnn.police.uk
(in case you've not worked it out get rid of Sick Of Spam to mail me!)
Web: ----------------------------------------
 
Ben,

This code is a vb executable that another application reads to determine where access is. From within the application this command is used: &quot;J:\gtllp\Access Databases\AccessCalls&quot;.

As you can see AccessCalls is used to find Access. To run your code instead where are you saying to put the &quot;call fHandleFile(DB,WIN_MAX)&quot;?

Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top