Execute 2nd Shell command if 1st is invalid (executing file paths) (1 Viewer)

neilwebber

Registered User.
Local time
Today, 19:59
Joined
Aug 19, 2002
Messages
35
Hello All

I have a shared database which contains a button which opens Arcview GIS and runs a script, zooming to a particular site depending on a value passed from access. The code on this button is given below.

My problem is.....

One of the users does not have Arcview installed on their PC but on a laptop (visible as M:\ on their PC). Therefore the line Shell("C:\etc") does not execute, it needs to be Shell("M:\etc") for this particular user.

Can anyone suggest some code to add so that:

If Shell("C:\etc") does not execute or is invalid or not found or whatever, then execute Shell("M:\etc") instead, but ignore Shell("M:\etc") if Shell("C:\etc") is True.

Alternatively, am I approaching this the wrong way and missing a more obvious alternative? I'm stumbling about in unknown territory here and any suggestions are warmly welcomed.

regards
Neil


The code:

Private Sub btnGoToAVBasics_Click()

If IsNull(DaughterSiteNumber) Then
Exit Sub
End If

On Error Resume Next

Dim chan As Variant
Dim request, answer As String
request = Forms![frmDaughterSites]![tblDaughterSitesSbf]![DaughterSiteNumber]
chan = DDEInitiate("arcview", "system")

If Err Then
Err = 0
I = Shell("C:\ESRI\AV_GIS30\ARCVIEW\bin32\ArcView C:\GIS\AccessProject\base.apr", 1)

If Err Then
MsgBox "DDE Connection Error"
Exit Sub
End If

chan = DDEInitiate("arcview", "system")
End If

DDERequest chan, "av.run(""ZoomFromAccess"",""" & request & """)"

DDETerminate chan

End Sub
 

FoFa

Registered User.
Local time
Today, 13:59
Joined
Jan 29, 2003
Messages
3,672
You could set a default parm the user can set, and have it set to C or in the one case M and pull it from there. I usually setup a parameters table and put things like that in there.
 

neilwebber

Registered User.
Local time
Today, 19:59
Joined
Aug 19, 2002
Messages
35
Hi FoFa

Thanks for your swift reply, much appreciated. I'm afraid parameter stuff is not one of my strong points so setting this up may be a little tricky for me (I wouldn't know where to start in truth!). I was hoping to go down the code route to keep it all neat and tidy and avoid users having to make any choices (users and choices don't mix in my experience).

I'll try to investigate your suggestion FoFa but in the meantime I'd still appreciate any suggestions on how to do this through VB if anyone else out there has any ideas.

cheers
Neil
 

bretto

Registered User.
Local time
Today, 19:59
Joined
Jun 25, 2003
Messages
29
If it's one user i would check the username (there are loads of examples of how to do this on the net) and then execute which ever path based on this information.

if username = myfunnyuser then
shell(c:\blah.exe)
else
shell(m:\blah.exe)
end if

Not great or ideal but fairly simple!!
 

neilwebber

Registered User.
Local time
Today, 19:59
Joined
Aug 19, 2002
Messages
35
bretto

Thanks for responding. I quite like this idea - I presume we're talking about Access user ID's as defined in a workgroup file/security permissions etc and not more general network login ID's?

I haven't got as far as assigning the users yet but when I do I'll certainly have a crack at this - now that that train of thought has left the station I can think of one or two other things that I'd like to do that would depend on a user's ID as well.

In the meantime, any straightforward vb based suggestions are still welcome from anyone (I'd just like to learn more about what I guess is an If..Then...Else statement. I could use these a lot if I had a better idea of the syntax).

many thanks
Neil
 

bretto

Registered User.
Local time
Today, 19:59
Joined
Jun 25, 2003
Messages
29
neilwebber said:
I presume we're talking about Access user ID's as defined in a workgroup file/security permissions etc and not more general network login ID's?

Either, on unsecured db's where everyone is admin you have to use network id so it depends on your situation. Using access users is easier syntax ("currentuser()") because to get the network login you need to make api calls, this may sound a bit daunting but there are loads of examples of this knocking about.
 

neilwebber

Registered User.
Local time
Today, 19:59
Joined
Aug 19, 2002
Messages
35
I do intend to set up proper admin/user permissions so this looks like the easiest way to do it. I've had a quick look at api calls and don't really like the look of that route (too complicated for me).

I'll post back to let any interested parties know how it goes.

cheers bretto

Neil
 

Users who are viewing this thread

Top Bottom