Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 11th, 2004, 11:19 AM
rkc rkc is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Seattle, WA, USA
Posts: 13 rkc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 56 m 24 sec
Reputation Power: 0
Question getting path and name of current Access program

Does anyone know of a way in Access XP, probably using Visual Basic code, to get the path and name of current Access program that is open? Basically, I am looking for something like "currentDB", which will tell me the path and name of the database which is currently open. But I want something like "currentAcc" to give me "C:\Program Files\Microsoft Office\Office\MSACCESS.EXE". This is obviously unnecessary if Access is always intalled in the same directory, but that is unfortunately not always the case. The Microsoft help file mentions something on MACs running OS 7.0 or higher, but nothing for PCs. Any help?

Reply With Quote
  #2  
Old October 11th, 2004, 01:34 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 21 h 32 m 23 sec
Reputation Power: 180
In Access VBA try

currentproject.name
currentproject.path
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #3  
Old October 11th, 2004, 01:59 PM
rkc rkc is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Seattle, WA, USA
Posts: 13 rkc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 56 m 24 sec
Reputation Power: 0
Exclamation not quite it

Doug,

This gives me the name of the database that I have open, rather than the access program (msaccess.exe) that has opened it. It is th elatter that I need.

Russ

Reply With Quote
  #4  
Old October 13th, 2004, 06:12 PM
JamesLe JamesLe is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Oakland, CA, USA
Posts: 131 JamesLe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m
Reputation Power: 4
RE: getting path and name of current Access program

Hello Russ,

You can get this path from windows registry key below:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Curr entVersion\App Paths\MSACCESS.EXE

You may need to use API functions to accomplish this. GetSetting and GetAllSetting function in access are limited for this purpose. Hope it will help.

Reply With Quote
  #5  
Old November 2nd, 2004, 12:32 PM
xidongzhang xidongzhang is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 4 xidongzhang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
That may not correct. If you install different versions of MS Access, such as Access 97, Access 2000 and Access XP (2002), etc. at the same machine, you may have trouble. The value from HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Curr entVersion\App Paths\MSACCESS.EXE may not be the path that you want. For my machine, I have installed three versions of MS Access. The path from HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Curr entVersion\App Paths\MSACCESS.EXE points to Access 97.

The better way to fulfill your objective is as following:

SysCmd(acSysCmdAccessDir) & "MSACCESS.EXE"


Quote:
Originally Posted by JamesLe
Hello Russ,

You can get this path from windows registry key below:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Curr entVersion\App Paths\MSACCESS.EXE

You may need to use API functions to accomplish this. GetSetting and GetAllSetting function in access are limited for this purpose. Hope it will help.

Reply With Quote
  #6  
Old November 2nd, 2004, 12:58 PM
JamesLe JamesLe is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Oakland, CA, USA
Posts: 131 JamesLe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m
Reputation Power: 4
Thank You

Hello xidongzhang,

Thanks for pointing that out! Just FYI: The value from HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Curr entVersion\App Paths\MSACCESS.EXE will be updated depending on which version of Access you are loading. But I like your SysCmd, I just learn it for the first time.

Reply With Quote
  #7  
Old November 14th, 2004, 05:16 AM
DoctorX DoctorX is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Kentucky
Posts: 21 DoctorX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to DoctorX
I have a question. What if you're trying to load this with a setup script program (I use Inno Setup) and want to access the current Access EXE? Is my only route to use the registry key above and expect them not to have multiple installations installed? See, the reason I want to do this is I have a workgroup file for Access user-level security and, without setting the Access default workgroup file for every machine, you can/have to use a shortcut of "[directory of access exe]\MSACCESS.EXE" "[location of MDB]\db.mdb" /wrkgrp "[directory of workgroup file]\wrkgrp.mdw".

Inno Setup can read registry keys and system constants, but, of course, couldn't tell me internally what the default Access directory is. And to be able to have the setup program create a shortcut based on their current Access directory, it has to be personalized to the individual computer. Thanks for any help!

Reply With Quote
  #8  
Old November 16th, 2004, 01:32 AM
Arjun Arjun is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 43 Arjun User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 18 sec
Reputation Power: 4
Can u

can you tell what is sysCmd ...? it gives an error message ... sub not defined...

i have coded :'

msgbox SysCmd(acSysCmdAccessDir) & "MSACCESS.EXE"


is it correct?

Arjun






Quote:
Originally Posted by xidongzhang
That may not correct. If you install different versions of MS Access, such as Access 97, Access 2000 and Access XP (2002), etc. at the same machine, you may have trouble. The value from HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Curr entVersion\App Paths\MSACCESS.EXE may not be the path that you want. For my machine, I have installed three versions of MS Access. The path from HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Curr entVersion\App Paths\MSACCESS.EXE points to Access 97.

The better way to fulfill your objective is as following:

SysCmd(acSysCmdAccessDir) & "MSACCESS.EXE"

Reply With Quote
  #9  
Old November 16th, 2004, 11:42 AM
JamesLe JamesLe is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Oakland, CA, USA
Posts: 131 JamesLe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m
Reputation Power: 4
Quote:
Originally Posted by DoctorX
I have a question. What if you're trying to load this with a setup script program (I use Inno Setup) and want to access the current Access EXE? Is my only route to use the registry key above and expect them not to have multiple installations installed? See, the reason I want to do this is I have a workgroup file for Access user-level security and, without setting the Access default workgroup file for every machine, you can/have to use a shortcut of "[directory of access exe]\MSACCESS.EXE" "[location of MDB]\db.mdb" /wrkgrp "[directory of workgroup file]\wrkgrp.mdw".

Inno Setup can read registry keys and system constants, but, of course, couldn't tell me internally what the default Access directory is. And to be able to have the setup program create a shortcut based on their current Access directory, it has to be personalized to the individual computer. Thanks for any help!
If Inno Setup can read registry keys then just try to read this key from your setup script. Again, it's always update the path value with the last version of Access you load if you have multiple version installed. HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Curr entVersion\App Paths\MSACCESS.EXE

Hope it works for you.

Reply With Quote
  #10  
Old November 16th, 2004, 11:49 AM
JamesLe JamesLe is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Oakland, CA, USA
Posts: 131 JamesLe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m
Reputation Power: 4
Quote:
Originally Posted by Arjun
can you tell what is sysCmd ...? it gives an error message ... sub not defined...

i have coded :'

msgbox SysCmd(acSysCmdAccessDir) & "MSACCESS.EXE"


is it correct?

Arjun
SysCmd is a function in Access VBA. It's not available in VB.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > getting path and name of current Access program


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway