Results 1 to 4 of 4

Thread: Microsoft Access / Visual Basic

  1. #1
    Join Date
    May 2003
    Posts
    10
    Rep Power
    0

    Default Microsoft Access / Visual Basic

    I'm trying to access a variable declared in a form from another form[s].
    I'm setting up a login screen to give only one user the authority to delete/edit the records. I'm using 2 unbound fields and all the codes are in button click. i just need to transfer the value true/false to allow/disable delete/edit.
    Any help one this would be appreciated.

  2. #2
    Join Date
    Feb 2003
    Posts
    3,184
    Rep Power
    0

    Default Re:Microsoft Access / Visual Basic

    Type the name of the form first then the variable/property/function or control that you want to access on that form.
    e.g.

    form1.deleteCrt.enabled=false
    or form1.var1 = false

    and so on. The little drop down menu should work as well but not all the time.

  3. #3
    Join Date
    Jun 2002
    Posts
    648
    Rep Power
    0

    Default Re:Microsoft Access / Visual Basic

    Don't really remember Access or VB but it would be good for you to build the app as object oriented as possible:

    Have 3 security tables:

    1) USER table - stores users of system
    2) PERMISSION table - list of permissions eg:- 'ADD', 'EDIT', 'DELETE' 'VIEW'
    2) USERPERMISSION Permissions - link users to permissions allowed


    ---------------------------------------------------------------
    Define a public function "HavePermission" :
    ---------------------------------------------------------------
    function: HavePermission
    2 parameters: Username and Permission
    Return: True or False

    In Delphi it would look something like this:

    function HavePermission(user: string; perm: string) : boolean;
    begin
    Result := false;
    //Lookup user, permission in USERPERMISSION table
    if (found) then
    Result := True;
    end;

    ---------------------------------------------------------------
    Also have a function that returns the current user signed in:
    ---------------------------------------------------------------
    function CurrentUser(): string;
    begin
    Result := <bla> <bla>;
    end;

    Now to prevent a user from having access to say a delete buttton do something like this:

    btnDelete.enabled := HavePermission(CurrentUser(), 'DELETE'

    or better yet:

    btnDelete.enabled := HavePermission(CurrentUser(), deletePerm());

    where public function deletePerm() is defined as 'DELETE' in your app.

    ---------------------------------
    Hope you find this useful especially in the future....
    and avoid using variables from other forms


  4. #4
    Join Date
    May 2003
    Posts
    10
    Rep Power
    0

    Default Re:Microsoft Access / Visual Basic

    Thanks RobyG

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •