Home All Groups Group Topic Archive Search About

join mdw from vba code

Author
9 Nov 2008 12:15 PM
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.

Author
9 Nov 2008 1:31 PM
Rick Brandt
Sefi Avuka wrote:
> 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.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com
Are all your drivers up to date? click for free checkup

Author
9 Nov 2008 1:58 PM
Sefi Avuka
Thank you for fast reply.
Is there a way i can stop the user after 3 "login atempts" to the mdw ?

sefi.

Show quoteHide quote
"Rick Brandt" wrote:

> Sefi Avuka wrote:
> > 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.
>
> --
> Rick Brandt, Microsoft Access MVP
> Email (as appropriate) to...
> RBrandt   at   Hunter   dot   com
>
>
>
Author
9 Nov 2008 2:21 PM
Rick Brandt
Sefi Avuka wrote:
> 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.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com
Author
9 Nov 2008 2:57 PM
Sefi Avuka
Thank you.


Show quoteHide quote
"Rick Brandt" wrote:

> Sefi Avuka wrote:
> > 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.
>
> --
> Rick Brandt, Microsoft Access MVP
> Email (as appropriate) to...
> RBrandt   at   Hunter   dot   com
>
>
>
>
>
>
Author
10 Nov 2008 12:49 AM
david
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)


Show quoteHide quote
"Sefi Avuka" <SefiAv***@discussions.microsoft.com> wrote in message
news:0D6801E5-048B-4687-A83A-A97B1F2F3120@microsoft.com...
> 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.

Bookmark and Share

Post Thread options