By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,336 Members | 2,315 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,336 IT Pros & Developers. It's quick & easy.

Shortcut to mdb...

P: n/a
I'm trying to make a shortcut that will open an mdb in the same folder as
the shortcut - regardless of where the file/shortcut may be. In other
words, I want to be able to copy and paste the two files anywhere and have
the shortcut always open the mdb that was copied with it without having to
change the shortcut properties. If I only use the mdb name without any
path, the shortcut tries to look in the folder where msaccess.exe is. I've
tried:

%cd%\MyDB.mdb
\MyDB.mdb
MyDB.mdb

None work.

Does anyone know how to do this?

Thanks.
--
Matthew.Wells
Ma***********@FirstByte.net
Aug 3 '08 #1
Share this Question
Share on Google+
10 Replies


P: n/a
I'm trying to make a shortcut that will open an mdb in the same folder as
the shortcut
if the person's going to be in the folder, what is the benefit of clicking
on the mdb file vs a shortcut in that folder? (I must be missing something
here).
In other words, I want to be able to copy and paste the two files anywhere
and have the shortcut always open the mdb that was copied with it without
having to change the shortcut properties.
I don't believe the above is possible, no more then having shortcut "know"
where you moved the file. On the other hand, what benefit is it to click on
the shortcut in the folder vs that of the actual mdb file? I guess I missing
a BIG issue here.

Now, if you talking about launching/running another mdb in the same folder
with vba code, then that's easy..but your asking for a shortcut which is a
grand canyon of difference of a question......

Why not click on the mdb file in place of a shortcut?
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
Aug 3 '08 #2

P: n/a
The Access version path and workgroup name are specified. These can change
depending on the MDB that's opened.
"Albert D. Kallal" <Pl*******************@msn.comwrote in message
news:Sxllk.111857$kx.35721@pd7urf3no...
>I'm trying to make a shortcut that will open an mdb in the same folder as
the shortcut

if the person's going to be in the folder, what is the benefit of clicking
on the mdb file vs a shortcut in that folder? (I must be missing something
here).
>In other words, I want to be able to copy and paste the two files
anywhere and have the shortcut always open the mdb that was copied with
it without having to change the shortcut properties.

I don't believe the above is possible, no more then having shortcut "know"
where you moved the file. On the other hand, what benefit is it to click
on the shortcut in the folder vs that of the actual mdb file? I guess I
missing a BIG issue here.

Now, if you talking about launching/running another mdb in the same folder
with vba code, then that's easy..but your asking for a shortcut which is a
grand canyon of difference of a question......

Why not click on the mdb file in place of a shortcut?
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com


Aug 3 '08 #3

P: n/a
"Matthew Wells" <Ma***********@FirstByte.netwrote in message
news:S7******************************@comcast.com. ..
The Access version path and workgroup name are specified. These can
change depending on the MDB that's opened.
Right, but can/are you trying to use vba to launch the mdb file, or a
shortcut?

As I said, with vba, this is easy, but you not clarified if you actually
need a shortcut, or in fact you can/are willing to run vba code to launch
the other mdb file?

An actual shortcut is quite problematic since even the location of the
msaccess.exe can change, let alone the path to the mdb file.

However, as mentioned, if you using vba here, then no problem....
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
Aug 3 '08 #4

P: n/a
The exe location will not change. Why would I use vba? Someone else
suggexted I use a batch file since the %cd% variable would be available
then. This would work easily, but I want to stick with the shortcut as we
already have the appropriate group policies in place for it. It would be
much easier to change the shortcut properties than to change the policies.
We are a public company and have SOX compliance issues.
"Albert D. Kallal" <Pl*******************@msn.comwrote in message
news:U0mlk.157849$gc5.5719@pd7urf2no...
"Matthew Wells" <Ma***********@FirstByte.netwrote in message
news:S7******************************@comcast.com. ..
>The Access version path and workgroup name are specified. These can
change depending on the MDB that's opened.
Right, but can/are you trying to use vba to launch the mdb file, or a
shortcut?

As I said, with vba, this is easy, but you not clarified if you actually
need a shortcut, or in fact you can/are willing to run vba code to launch
the other mdb file?

An actual shortcut is quite problematic since even the location of the
msaccess.exe can change, let alone the path to the mdb file.

However, as mentioned, if you using vba here, then no problem....
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com


Aug 3 '08 #5

P: n/a
"Matthew Wells" <Ma***********@FirstByte.netwrote in message
news:L7******************************@comcast.com. ..
The exe location will not change.
Might be your case, but then again why not code something that will work
when the user has a non standard install location...and this especially
happens with a2003 runtime, or in the case that they installed into a
different folder. I mean, ***why*** would you not using something that more
flexible then a hard coded path that can change? It would a VERY silly idea
to choose a hard coded path to msaccess.exe if you can get the path on the
fly. (not a big deal either way, but when using vba, it no more work to get
the actuall path).
Why would I use vba?
Because vba makes the whole problem trivial. I not really telling you to use
vba, I simply asking what you are trying to do, and ***can*** you consider
using vba (since this is a walk in the park).

So, I am actually asking **can** you use vba here?
Someone else suggexted I use a batch file since the %cd% variable would
be available then.
Well, it was not me, and it not clear what your trying to do here...

So, a batch file for what? Who is running that batch file? What is it going
to do? Is this to be run from access? As I said if this can be a mdb/mde
file they click on then this is quite easy. It just not clear if you do in
fact need a batch file (and batch files are not a ms-access question
anyway).

I don't have an answer for using dos batch files, but if we are taking about
VBA, then I can dig up a solution for you. We just have to determine if you
MUST use batch file + shortcut (and, if you must use a batch file then me
digging up some vba is going to waste both yours and my time).

All of this info such as the current path, path to msaccess.exe and even the
path to the currently joined workgroup file is easily obtained in ms-access,
but not so much in batch files.
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
Aug 3 '08 #6

P: n/a
Perhaps I not grabbing what you want to do.

However, here is how from inside of ms-access you can launch another
application (in the same dir), and also specify he location of ms-access and
also the workgroup file...
Function JumpToUpGrade2() As Boolean

' jumps to a mde file called "upgrade"
' it exists in the same directly as the currently running program

Dim strExe As String
Dim strShellProg As String
Dim strCurrentDir As String
Dim strDB As String
Dim strWorkGrp As String
Const q As String = """"

Dim fhand As Integer
Dim strCopyFile As String
Dim strRidesini As String
strDB = CurrentDb.Name

strCurrentDir = CurrentProject.Path & "\"

'get path to msaccess.exe
strShellProg = q & SysCmd(acSysCmdAccessDir) & "msaccess.exe" & q
' we will shell out to RidesUpGrade.mde
strShellProg = strShellProg & " " & q & strCurrentDir &
"RidesUpGrade.mdE" & q
' get workgroup file
strWorkGrp = q & SysCmd(acSysCmdGetWorkgroupFile) & q

strShellProg = strShellProg & " /wrkGrp " & strWorkGrp
If Shell(strShellProg, vbNormalFocus) 0 Then
Application.Quit
Else
MsgBox "Un able to run Rides upgrade", vbCritical, AppName
Application.Quit
End If
End Function
So, the above shows how you can grab the current path of the current running
application (get your dir).

eg:
strCurrentDir = CurrentProject.Path & "\"

path to ms-access.exe

strShellProg = q & SysCmd(acSysCmdAccessDir) & "msaccess.exe" & q

path to workgroup
strWorkGrp = q & SysCmd(acSysCmdGetWorkgroupFile) & q

However, as mentioned, if you must use a batch file, then all of the above
is simply not going to help you....

However, if you are looking to launching something from the same dir via
ms-access then the above info should be just the ticket you are looking
for...

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
Aug 4 '08 #7

P: n/a
"Matthew Wells" <Ma***********@FirstByte.netwrote:
>I'm trying to make a shortcut that will open an mdb in the same folder as
the shortcut - regardless of where the file/shortcut may be. In other
words, I want to be able to copy and paste the two files anywhere and have
the shortcut always open the mdb that was copied with it without having to
change the shortcut properties. If I only use the mdb name without any
path, the shortcut tries to look in the folder where msaccess.exe is. I've
tried:
FWIW the Auto FE Updater can, essentially, do all this for you and copy down new
versions of the FE when you make them available.

Actually what it does is call the FE MDB/MDE with the appropriate command line
switches such as the work group.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Aug 5 '08 #8

P: n/a
I want to use a Windows shortcut. I'm not opening from within an app. We
have different environments that use the same db name (Dev, UAT, and
Production). There has been confustion on which shortcut opened which db.
We want to make sure tha tthe shortcut can only open the mdb in the same
folder as the shortcut.

I'm sorry you feel like I should justify my methodology. Do you actually
have an answer? I would appreciate it.

"Albert D. Kallal" <Pl*******************@msn.comwrote in message
news:Njslk.158813$gc5.43486@pd7urf2no...
Perhaps I not grabbing what you want to do.

However, here is how from inside of ms-access you can launch another
application (in the same dir), and also specify he location of ms-access
and also the workgroup file...
Function JumpToUpGrade2() As Boolean

' jumps to a mde file called "upgrade"
' it exists in the same directly as the currently running program

Dim strExe As String
Dim strShellProg As String
Dim strCurrentDir As String
Dim strDB As String
Dim strWorkGrp As String
Const q As String = """"

Dim fhand As Integer
Dim strCopyFile As String
Dim strRidesini As String
strDB = CurrentDb.Name

strCurrentDir = CurrentProject.Path & "\"

'get path to msaccess.exe
strShellProg = q & SysCmd(acSysCmdAccessDir) & "msaccess.exe" & q
' we will shell out to RidesUpGrade.mde
strShellProg = strShellProg & " " & q & strCurrentDir &
"RidesUpGrade.mdE" & q
' get workgroup file
strWorkGrp = q & SysCmd(acSysCmdGetWorkgroupFile) & q

strShellProg = strShellProg & " /wrkGrp " & strWorkGrp
If Shell(strShellProg, vbNormalFocus) 0 Then
Application.Quit
Else
MsgBox "Un able to run Rides upgrade", vbCritical, AppName
Application.Quit
End If
End Function
So, the above shows how you can grab the current path of the current
running application (get your dir).

eg:
strCurrentDir = CurrentProject.Path & "\"

path to ms-access.exe

strShellProg = q & SysCmd(acSysCmdAccessDir) & "msaccess.exe" & q

path to workgroup
strWorkGrp = q & SysCmd(acSysCmdGetWorkgroupFile) & q

However, as mentioned, if you must use a batch file, then all of the above
is simply not going to help you....

However, if you are looking to launching something from the same dir via
ms-access then the above info should be just the ticket you are looking
for...

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com

Aug 6 '08 #9

P: n/a
?????? So it's not a shortcut to the mdb but a shortcut to ms-access
with the mdb specified as a command line parameter?

On Aug 3, 1:23*pm, "Matthew Wells" <Matthew.We...@FirstByte.net>
wrote:
The Access version path and workgroup name are specified. *These can change
depending on the MDB that's opened.
Aug 6 '08 #10

P: n/a
"Matthew Wells" <Ma***********@FirstByte.netwrote in message
news:Ao******************************@comcast.com. ..
>I want to use a Windows shortcut. I'm not opening from within an app. We
have different environments that use the same db name (Dev, UAT, and
Production). There has been confustion on which shortcut opened which db.
We want to make sure tha tthe shortcut can only open the mdb in the same
folder as the shortcut.

I'm sorry you feel like I should justify my methodology.
I am not asking you to justify your approach, but I am simply telling you if
can use vba then I have an easy solution for you. Nothing more, nothing
less.
Do you actually have an answer? I would appreciate it.
No, I only have a vba one for you.
Why on earth would I withhold an answer? How stupid is that? I taken time to
offer you examples that work in VBA + ms-access. Unfortunately that's the
only
solution I have here for you here (sorry). And, I spend considerable time
asking you is a vba solution ok? The **reason** why I asked you if a vba
solution is ok because then I would be willing to spend the time offering
that soltuion. (not that you "must" use vba, or change your ways).

However, you were NOT forthcommming on this issue so I simply
offered the soltion and now we see it was a compliate 100% waste of my time
that could have been used to help others here. I was asking out of
respect and to save time here.

Since you can't use vba and ms-access then you asking your question in the
wrong newsgroup and you unlikey to find an answer here.

I also think you would be better off using windows scriting in place of a
shrotcut, but then again you made your restrucitons clear now.

Perahps you try some other windows support forms, but you much shooting in
the dark for a non access soltiuon by asking in a access group...
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com

Aug 7 '08 #11

This discussion thread is closed

Replies have been disabled for this discussion.