Simple If....Then code (1 Viewer)

kirsty

Registered User.
Local time
Today, 03:20
Joined
Nov 5, 1999
Messages
19
Hi,

I am stuck on what seems to be a fairly simple procedure!

I have written the following code:-

Private Sub pass_AfterUpdate()

'Validate data input - if correct password is entered then open 'Claim form' and if wrong password is entered add a msg box to tell user this password is wrong.

If Me![pass] = "KIRSTY" Then
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Claimform"
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit
DoCmd.GoToRecord acDataForm, "Claimform",
DoCmd.Close acForm, "password"

ElseIf Me![pass] = "*" Then
MsgBox "This is incorrect! Please try again."
DoCmd.GoToControl "pass"

End If


The ElseIf part doesn't seem to be working.

Basically, I am trying to write code so if any other text apart from kirsty is entered a msgbox appears. I can get this to work, however, I want the previous text entry to have been deleted when the user goesback into the control.

Does anyone out there no how to do this?

Many thanks,

Kirsty.
End Sub
 

mikec

Registered User.
Local time
Today, 03:20
Joined
Dec 17, 1999
Messages
22
Kirsty,

A simple line of
me.pass = null
inserted in your else statement should do the trick.
 

ListO

Señor Member
Local time
Today, 03:20
Joined
Feb 2, 2000
Messages
162
Are you testing for M![Pass] to equal an asterisk, or is the asterisk supposed to represent a wildcard? If you're thinking wildcard, then

Instead of using:
Else If Me![pass]="*"
(Mssg box, etc)

couldn't you just use:
Else
(Msg Box, etc.)
You have already tested for the string to equal "Kirsty" in the IF part of the statement, and if it's not "Kirsty" it the ELSE code should execute.
 
C

ChrisS

Guest
Kirsty,

Have you considered having a password field in a staff table, or a separate password table. Hardcoding passwords can be a real pain!!!
 

Users who are viewing this thread

Top Bottom