donkey9972
Registered User.
- Local time
- Yesterday, 22:48
- Joined
- May 18, 2008
- Messages
- 39
Hi,
I was wondering if someone could help me with a little problem. I am making a login form which has a user account creation page. The problem I am having is on the user account creation page. I am using the following code:
My problem arises when you click save. What I want to happen is a way to ensure that all fields (First name, Last name, Username, Password) are all filled in. If one of the fields are not filled in, then I want a message box to appear and inform the user-to-be that they missed something. I have set the following conditions on the table:
Validation rule = is not null
Validation text = "required"
Required = Yes
Allow zero length = No
I relized after that fact my fields are unbound on my form, so those would not do anything. I then tried to use the following code in the form before update:
But it has no effect on anything, the account is still created even if information is missing. Other than this issue, my form works perfectly.
I was wondering if someone could help me with a little problem. I am making a login form which has a user account creation page. The problem I am having is on the user account creation page. I am using the following code:
Code:
Private Sub btnSave_Click()
DoCmd.SetWarnings False
If IsNull(Me.txtxID) Then
If Not Me.txtConfirmPassword = Me.txtPassword Then
MsgBox "Please check your password!", vbInformation, "Information"
Exit Sub
Else
DoCmd.RunSQL ("INSERT into tlogin (firstname, lastname, username, password) Values (""" & Me.txtFirstName & """ , """ & Me.txtLastName & """ , """ & Me.txtusername & """ , """ & Me.txtPassword & """ )")
MsgBox "account created", vbInformation, "Information"
DoCmd.Close
DoCmd.OpenForm "flogin"
End If
End If
End Sub
My problem arises when you click save. What I want to happen is a way to ensure that all fields (First name, Last name, Username, Password) are all filled in. If one of the fields are not filled in, then I want a message box to appear and inform the user-to-be that they missed something. I have set the following conditions on the table:
Validation rule = is not null
Validation text = "required"
Required = Yes
Allow zero length = No
I relized after that fact my fields are unbound on my form, so those would not do anything. I then tried to use the following code in the form before update:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.txtFirstName) Or Me.txtLastName Or Me.txtusername Or Me.txtPassword = "" Then
MsgBox "This field is required.", vbExclamation, "Required Field"
Me.txtRequiredField.SetFocus
Cancel = True
End If
End Sub
But it has no effect on anything, the account is still created even if information is missing. Other than this issue, my form works perfectly.
Last edited: