I am a PB newbie. I want to create a Login window and check for username/pw and display the appropriate error message. If incorrect clear the SingleLineEdit field and set the focus to enter a new username/pw. Here's my code:
//Local variables
String ls_usnInput, ls_pwInput, crs_name, crs_pw
Boolean lb_loginOK = false
DO
ls_usnInput = Trim (sle_username.text)
ls_pwInput = Trim (sle_password.text)
DECLARE Login CURSOR FOR
SELECT username, password
FROM Users
WHERE username = :ls_usnInput
USING LADSTrans;
OPEN Login;
FETCH Login INTO :crs_name, :crs_pw;
CLOSE Login;
crs_name = Trim (crs_name)
crs_pw = Trim (crs_pw)
If crs_name <> ls_usnInput OR ls_usnInput = "" Then
Messagebox ("Login Error", "Please enter a valid user name."
sle_username.SelectText(1, Len(sle_username.Text))
sle_username.Clear( )
sle_username.setfocus()
ElseIf crs_pw <> ls_pwInput OR ls_pwInput = "" Then
Messagebox ("Login Error", "Please enter a valid password."
sle_password.SelectText(1, Len(sle_password.Text))
sle_password.Clear( )
sle_password.Setfocus( )
Else
lb_loginOK = true
End If
LOOP UNTIL lb_loginOK = TRUE
Close (parent);
What currently happens is an infinite looping of the Messagebox because I can't get back to the Login window's SingleLineEdit to enter a new username. Can any1 help plz?
//Local variables
String ls_usnInput, ls_pwInput, crs_name, crs_pw
Boolean lb_loginOK = false
DO
ls_usnInput = Trim (sle_username.text)
ls_pwInput = Trim (sle_password.text)
DECLARE Login CURSOR FOR
SELECT username, password
FROM Users
WHERE username = :ls_usnInput
USING LADSTrans;
OPEN Login;
FETCH Login INTO :crs_name, :crs_pw;
CLOSE Login;
crs_name = Trim (crs_name)
crs_pw = Trim (crs_pw)
If crs_name <> ls_usnInput OR ls_usnInput = "" Then
Messagebox ("Login Error", "Please enter a valid user name."
sle_username.SelectText(1, Len(sle_username.Text))
sle_username.Clear( )
sle_username.setfocus()
ElseIf crs_pw <> ls_pwInput OR ls_pwInput = "" Then
Messagebox ("Login Error", "Please enter a valid password."
sle_password.SelectText(1, Len(sle_password.Text))
sle_password.Clear( )
sle_password.Setfocus( )
Else
lb_loginOK = true
End If
LOOP UNTIL lb_loginOK = TRUE
Close (parent);
What currently happens is an infinite looping of the Messagebox because I can't get back to the Login window's SingleLineEdit to enter a new username. Can any1 help plz?