join mdw from vba code

  • Thread starter Thread starter Sefi Avuka
  • Start date Start date
S

Sefi Avuka

How can I join a .mdw file from vba code ?
i want to open my database without mdw, and then join to the workgroup fro
vba.

sample code will be good.

Thanks.
 
Sefi said:
How can I join a .mdw file from vba code ?
i want to open my database without mdw, and then join to the
workgroup fro vba.

sample code will be good.

Thanks.

You cannot open Access without an MDW and you cannot switch MDWs once Access
is opened. You can in code open a new workspace that uses a different MDW
and then use that workspace to programmatically interact with another
database file, but you cannot switch the workgroup for the active session.
 
Thank you for fast reply.
Is there a way i can stop the user after 3 "login atempts" to the mdw ?

sefi.
 
Sefi said:
Thank you for fast reply.
Is there a way i can stop the user after 3 "login atempts" to the mdw

No, because you cannot run any code or macro until they are in. If I
understand what you are trying to do you can do this...

You can secure with a non-default MDW a file that is secured traditionally.
That is, a user name that is NOT "Admin" is required to get in. At the same
time you can create a non-secured "launcher" file that can be opened without
being prompted. This is the file your users actually open.

Within that file you can prompt the user for their credentials to open the
main file. You can use a workspace in code to see if the credentials are
any good. If they are you then use them to open the main file while closing
the other specifying your secure workgroup file and passing their
credentials as command line arguments. Since you are prompting them for
their credentials within the environment of the launcher file you have
pretty much total control over that process. You can limit how many
attempts they get, display custom messages, etc..

If all of this sounds like a LOT of work for little benefit I absolutely
agree. In my opinion Access User Level Security does not pass the
cost/benefit test even when used the "normal" way. It's a lot of work, most
people get it wrong (often without realizing it), and it is easily hacked by
someone who really wants to.
 
Thank you.


Rick Brandt said:
No, because you cannot run any code or macro until they are in. If I
understand what you are trying to do you can do this...

You can secure with a non-default MDW a file that is secured traditionally.
That is, a user name that is NOT "Admin" is required to get in. At the same
time you can create a non-secured "launcher" file that can be opened without
being prompted. This is the file your users actually open.

Within that file you can prompt the user for their credentials to open the
main file. You can use a workspace in code to see if the credentials are
any good. If they are you then use them to open the main file while closing
the other specifying your secure workgroup file and passing their
credentials as command line arguments. Since you are prompting them for
their credentials within the environment of the launcher file you have
pretty much total control over that process. You can limit how many
attempts they get, display custom messages, etc..

If all of this sounds like a LOT of work for little benefit I absolutely
agree. In my opinion Access User Level Security does not pass the
cost/benefit test even when used the "normal" way. It's a lot of work, most
people get it wrong (often without realizing it), and it is easily hacked by
someone who really wants to.
 
Check the mdw on startup:

application.SysCmd(acSysCmdGetWorkgroupFile)

If the workgroup is wrong, start another copy of your
database using the correct workgroup:

s = application.SysCmd(acSysCmdAccessDir)
s = "'" & s & "msaccess.exe" & "'" & " "
s = s & "'" & currentdb.name & "'"
s = s & " /wrkgrp=" & mycorrectworkgroup

vba.shell(s)

quit the old copy of the database

Application.quit


(david)
 
Back
Top