Macro Conditional Statement

P

Patrick

I'm trying to use a simple statement that compares two values in a table of
mine. If they are the same and the statement is true, the application will
open a new form. If it is false, then the application will throw up an
error. This is just an implementation of a password for each user. The
statement I am using is: [Emp].[EmpPW]=[Emp].[PwCurrent]

Will this work? When I run the app., nothing happens and I don't get an
error.
 
L

Larry Daugherty

The statement you've given sets EmpPW to what is in PWCurrent. You don't
show any error code. It's sometimes helpful to do simple things like that
in the Immediate window so that you can check values right away.

HTH
 
P

Patrick

Actually I switched the statement to :
[Forms]![PwForm]![EmpPW]=[Forms]![PwForm]![PwCurrent]

This actually does work. The statement does not set a value of one to the
other. In the conditional box, it only checks to see if the statement is
true or false.

Larry Daugherty said:
The statement you've given sets EmpPW to what is in PWCurrent. You don't
show any error code. It's sometimes helpful to do simple things like that
in the Immediate window so that you can check values right away.

HTH
--
-Larry-
--

Patrick said:
I'm trying to use a simple statement that compares two values in a table of
mine. If they are the same and the statement is true, the application will
open a new form. If it is false, then the application will throw up an
error. This is just an implementation of a password for each user. The
statement I am using is: [Emp].[EmpPW]=[Emp].[PwCurrent]

Will this work? When I run the app., nothing happens and I don't get an
error.
 
S

Steve Schapel

Patrick,

That's good. If your macro is being run from an event on the PwForm
form, you can dispense with the form reference, and just do it like this...
[EmpPW]=[PwCurrent]

You can't check the value of table or query fields in this way, as
Access has no way of knowing which record you are referring to. If you
wanted to check the password entered on the form against the value in a
table, you can use the DLookup() function.
 
Top