Logging off

G

Guest

Dim sCommand As String, lTaskID As Long
sCommand = """" & SysCmd(acSysCmdAccessDir) & "msaccess.exe """ _
& CurrentDb.Name &
""c\finalproject\sjacadets.mdb"/wrkgrp:c:\finalproject\system.mdw""" &
SysCmd(acSysCmdGetWorkgroupFile) _
& """" ' and add any other switches you require here
lTaskID = Shell(sCommand, vbMaximizedFocus)
If lTaskID <> 0 Then AppActivate lTaskID
DoCmd.Quit


can anyone tell me if this code is correct, and if not supply a suggestion
thanks in advance
 
G

Graham Mandeno

No, your code will certainly not work. As well as including two databases
and two workgroup files, you have missed out a colon in the C:\ for the
database file.

Do you want to open the same database with the same workgroup file as the
one you currently have open?

If so, then I repeat, there is no need to put the actual filenames into your
command string. You can just use SysCmd and CurrentDb.Name to ascertain all
that:

sCommand = """" & SysCmd(acSysCmdAccessDir) & "msaccess.exe"" """ _
& CurrentDb.Name & """ /wrkgrp:""" _
& SysCmd(acSysCmdGetWorkgroupFile) & """"

If you wish, you /can/ hard-code the file names of both the database and the
workgroup file, but that means you will need to change the code if either of
those files ever moves to a different location:

sCommand = """" & SysCmd(acSysCmdAccessDir) & "msaccess.exe"" " _
& "c:\finalproject\sjacadets.mdb" /wrkgrp:c:\finalproject\system.mdw"
 
G

Guest

Thank you very much, it needed to be hard coded as it didn't seem to open the
actual database with the automatic version however there was one small error
in your code


sCommand = """" & SysCmd(acSysCmdAccessDir) & "msaccess.exe"" " _
& "c:\finalproject\sjacadets.mdb" /wrkgrp:c:\finalproject\system.mdw"
you do not need the speech marks in between, mdb" /wrkgrp it should just be
mdb /wrkgrp

anyway thank you very much that is one very big problem solved.
Graham Mandeno said:
No, your code will certainly not work. As well as including two databases
and two workgroup files, you have missed out a colon in the C:\ for the
database file.

Do you want to open the same database with the same workgroup file as the
one you currently have open?

If so, then I repeat, there is no need to put the actual filenames into your
command string. You can just use SysCmd and CurrentDb.Name to ascertain all
that:

sCommand = """" & SysCmd(acSysCmdAccessDir) & "msaccess.exe"" """ _
& CurrentDb.Name & """ /wrkgrp:""" _
& SysCmd(acSysCmdGetWorkgroupFile) & """"

If you wish, you /can/ hard-code the file names of both the database and the
workgroup file, but that means you will need to change the code if either of
those files ever moves to a different location:

sCommand = """" & SysCmd(acSysCmdAccessDir) & "msaccess.exe"" " _
& "c:\finalproject\sjacadets.mdb" /wrkgrp:c:\finalproject\system.mdw"

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

rhann said:
Dim sCommand As String, lTaskID As Long
sCommand = """" & SysCmd(acSysCmdAccessDir) & "msaccess.exe """ _
& CurrentDb.Name &
""c\finalproject\sjacadets.mdb"/wrkgrp:c:\finalproject\system.mdw""" &
SysCmd(acSysCmdGetWorkgroupFile) _
& """" ' and add any other switches you require here
lTaskID = Shell(sCommand, vbMaximizedFocus)
If lTaskID <> 0 Then AppActivate lTaskID
DoCmd.Quit


can anyone tell me if this code is correct, and if not supply a suggestion
thanks in advance
 
G

Graham Mandeno

Glad you got it working :)

Yes, you are right - that extra quote was left over from when the next thing
in the string was CurrentDb.name.

The embedded quotes in the string are necessary only if the file names have
spaces in them.

I still don't like the hidea of hard-coding the file names. Are you
absolutely sure that this doesn't work?:
sCommand = """" & SysCmd(acSysCmdAccessDir) & "msaccess.exe"" """ _
& CurrentDb.Name & """ /wrkgrp:""" _
& SysCmd(acSysCmdGetWorkgroupFile) & """"

--
Graham Mandeno [Access MVP]
Auckland, New Zealand


rhann said:
Thank you very much, it needed to be hard coded as it didn't seem to open
the
actual database with the automatic version however there was one small
error
in your code


sCommand = """" & SysCmd(acSysCmdAccessDir) & "msaccess.exe"" " _
& "c:\finalproject\sjacadets.mdb" /wrkgrp:c:\finalproject\system.mdw"
you do not need the speech marks in between, mdb" /wrkgrp it should just
be
mdb /wrkgrp

anyway thank you very much that is one very big problem solved.
Graham Mandeno said:
No, your code will certainly not work. As well as including two databases
and two workgroup files, you have missed out a colon in the C:\ for the
database file.

Do you want to open the same database with the same workgroup file as the
one you currently have open?

If so, then I repeat, there is no need to put the actual filenames into
your
command string. You can just use SysCmd and CurrentDb.Name to ascertain
all
that:

sCommand = """" & SysCmd(acSysCmdAccessDir) & "msaccess.exe"" """ _
& CurrentDb.Name & """ /wrkgrp:""" _
& SysCmd(acSysCmdGetWorkgroupFile) & """"

If you wish, you /can/ hard-code the file names of both the database and
the
workgroup file, but that means you will need to change the code if either
of
those files ever moves to a different location:

sCommand = """" & SysCmd(acSysCmdAccessDir) & "msaccess.exe"" " _
& "c:\finalproject\sjacadets.mdb" /wrkgrp:c:\finalproject\system.mdw"

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

rhann said:
Dim sCommand As String, lTaskID As Long
sCommand = """" & SysCmd(acSysCmdAccessDir) & "msaccess.exe """ _
& CurrentDb.Name &
""c\finalproject\sjacadets.mdb"/wrkgrp:c:\finalproject\system.mdw""" &
SysCmd(acSysCmdGetWorkgroupFile) _
& """" ' and add any other switches you require here
lTaskID = Shell(sCommand, vbMaximizedFocus)
If lTaskID <> 0 Then AppActivate lTaskID
DoCmd.Quit


can anyone tell me if this code is correct, and if not supply a
suggestion
thanks in advance
 
G

Guest

yes I tried it all but as it is easier to have it hard coded, as I can change
the file path

Graham Mandeno said:
Glad you got it working :)

Yes, you are right - that extra quote was left over from when the next thing
in the string was CurrentDb.name.

The embedded quotes in the string are necessary only if the file names have
spaces in them.

I still don't like the hidea of hard-coding the file names. Are you
absolutely sure that this doesn't work?:
sCommand = """" & SysCmd(acSysCmdAccessDir) & "msaccess.exe"" """ _
& CurrentDb.Name & """ /wrkgrp:""" _
& SysCmd(acSysCmdGetWorkgroupFile) & """"

--
Graham Mandeno [Access MVP]
Auckland, New Zealand


rhann said:
Thank you very much, it needed to be hard coded as it didn't seem to open
the
actual database with the automatic version however there was one small
error
in your code


sCommand = """" & SysCmd(acSysCmdAccessDir) & "msaccess.exe"" " _
& "c:\finalproject\sjacadets.mdb" /wrkgrp:c:\finalproject\system.mdw"
you do not need the speech marks in between, mdb" /wrkgrp it should just
be
mdb /wrkgrp

anyway thank you very much that is one very big problem solved.
Graham Mandeno said:
No, your code will certainly not work. As well as including two databases
and two workgroup files, you have missed out a colon in the C:\ for the
database file.

Do you want to open the same database with the same workgroup file as the
one you currently have open?

If so, then I repeat, there is no need to put the actual filenames into
your
command string. You can just use SysCmd and CurrentDb.Name to ascertain
all
that:

sCommand = """" & SysCmd(acSysCmdAccessDir) & "msaccess.exe"" """ _
& CurrentDb.Name & """ /wrkgrp:""" _
& SysCmd(acSysCmdGetWorkgroupFile) & """"

If you wish, you /can/ hard-code the file names of both the database and
the
workgroup file, but that means you will need to change the code if either
of
those files ever moves to a different location:

sCommand = """" & SysCmd(acSysCmdAccessDir) & "msaccess.exe"" " _
& "c:\finalproject\sjacadets.mdb" /wrkgrp:c:\finalproject\system.mdw"

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Dim sCommand As String, lTaskID As Long
sCommand = """" & SysCmd(acSysCmdAccessDir) & "msaccess.exe """ _
& CurrentDb.Name &
""c\finalproject\sjacadets.mdb"/wrkgrp:c:\finalproject\system.mdw""" &
SysCmd(acSysCmdGetWorkgroupFile) _
& """" ' and add any other switches you require here
lTaskID = Shell(sCommand, vbMaximizedFocus)
If lTaskID <> 0 Then AppActivate lTaskID
DoCmd.Quit


can anyone tell me if this code is correct, and if not supply a
suggestion
thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top