-
Jun 11, 2003, 12:59 PM
#1
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.
-
Jun 11, 2003, 01:33 PM
#2
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.
-
Jun 11, 2003, 05:24 PM
#3
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
-
Jun 16, 2003, 12:32 PM
#4
Re:Microsoft Access / Visual Basic
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules