"Dlookup" verification in macro

  • Thread starter Thread starter Billy
  • Start date Start date
B

Billy

With the help of Mr. Steve Schapel, I created a macro that
looks at an employee table and if the password and userid
are correct, then it opens up a form (1). This particular
condition looks like this:

[password]=DLookUp("[password]","employee","[employee ID]
= '" & [username] & "'")

My problem is that I need to Enable a button on form (1)
if and only username QAS-000 logs on. So, I tried simply
creating a condition like this:
[username]="QAS-000" then set value of button to enabled.
but I get an error because if the "Dlookup" condition
is "FALSE"; the macro continues and when it arrives at
[username="QAS-000" and hence the form is not open, I
receive the expected error that the form can't be found.

Not only that but the condition is ony based on the fact
that username QAS-000 is selected, regardless of whether a
correct password is typed.

I there a way a can set a condition that states:

If QAS-000 meets the conditions set forth by the Dlookup
condition then do a setvalue. Basically, Im looking at a
way of verifying that if "Dlookup" condition is TRUE and
username QAS-000 logged on then do a setvalue. thanks for
the help

Billy
 
Billy,

Two approaches to this...
1. Repeat the Dlookup as part of the condition for the SetValue
action, e.g.
[password]=DLookUp("[password]","employee","[employee ID] = '" &
[username] & "'") And [username]="QAS-000"

2. Put your SetValue action as a separate macro (can be within the
same macro group), just with the [username]="QAS-000" condition, and
in the first macro add a RunMacro action, Condition ... (ellipsis), to
run the second macro.

- Steve Schapel, Microsoft Access MVP
 
It sounds like this button is for security. Why not hide
the button except for user QAS-000.

If CurrentUser = "QAS-000" Then
buttonname.Visible = True
Else
buttonname.Visible = False

End If

Jim
-----Original Message-----
Billy,

Two approaches to this...
1. Repeat the Dlookup as part of the condition for the SetValue
action, e.g.
[password]=DLookUp("[password]","employee","[employee ID] = '" &
[username] & "'") And [username]="QAS-000"

2. Put your SetValue action as a separate macro (can be within the
same macro group), just with the [username]="QAS-000" condition, and
in the first macro add a RunMacro action, Condition ... (ellipsis), to
run the second macro.

- Steve Schapel, Microsoft Access MVP


With the help of Mr. Steve Schapel, I created a macro that
looks at an employee table and if the password and userid
are correct, then it opens up a form (1). This particular
condition looks like this:

[password]=DLookUp("[password]","employee","[employee ID]
= '" & [username] & "'")

My problem is that I need to Enable a button on form (1)
if and only username QAS-000 logs on. So, I tried simply
creating a condition like this:
[username]="QAS-000" then set value of button to enabled.
but I get an error because if the "Dlookup" condition
is "FALSE"; the macro continues and when it arrives at
[username="QAS-000" and hence the form is not open, I
receive the expected error that the form can't be found.

Not only that but the condition is ony based on the fact
that username QAS-000 is selected, regardless of whether a
correct password is typed.

I there a way a can set a condition that states:

If QAS-000 meets the conditions set forth by the Dlookup
condition then do a setvalue. Basically, Im looking at a
way of verifying that if "Dlookup" condition is TRUE and
username QAS-000 logged on then do a setvalue. thanks for
the help

Billy

.
 
Back
Top