Good afternoon how can i modify this code to exit sub if the person is already registered or go to the registration code if that person is not registered thanks in advance
B4X:
If CCode.Text = "" Or Phone.Text = "" Or Emails.Text = "" Then
Msgbox("You have to enter all fields","Missed data field")
Else
cursor1 = SQL1.ExecQuery("SELECT * FROM Register where Phone = '" & Phone.Text & "' ")
For i = 0 To cursor1.RowCount - 1
'cursor1.Position = i
Msgbox("You are Already Registered","SMIS")
Next
Return
'Else
'If CCode.Text = "256" Then
DBloadnew
End If
End Sub
Sub DBloadnew
cursor1 = SQL1.ExecQuery("SELECT ID FROM Register")
If cursor1.RowCount > 0 Then
For i = 0 To cursor1.RowCount - 1
cursor1.Position = i
Dim NewID As Int
NewID = cursor1.GetInt("ID")
Next
End If
NewID = NewID +1 '
SQL1.ExecNonQuery("INSERT INTO Register VALUES('" & CCode.Text & "','" & Phone.Text & "','" & Emails.Text & "','" & NewID & "')")
'SQL1.ExecNonQuery("INSERT INTO Register VALUES('" & CCode.Text & "','" & Phone.Text & "','" & Emails.Text & "')")
Msgbox("Registration Completed Successfully","SMIS")
'End If