How to Create Registration Form

How to Create Registration Form: MS Access

The registration form is provided for a new user to create his/her profile. The user can choose his/her own LoginID and Password in order to open the database. We need a table and a form to complete a Registration form. The registration information will be saved into the table called tblUser in this example. Follow step by step below:

1) Create a table called tblUser (or name something else). In this HowTo, you need a user full name, login ID, password, user type, address …etc. If you need help with creating a form then follow my How to Create Form for beginner. tabledesign







2) Create a Registration Form with a Record Source = tblUser. Under the Other tab of Property Sheet, set Pop Up and Modal both to Yes.recordSorcesetModal






3) Change a form format as Record Selectors = No Navation Buttons = No Control Box = No Close Button = No Min Max Buttons = None



4) Change a form data entry to “Yes” to show a blank form for a new registration  dataentryNo







5) Add two buttons at the bottom of the Registration form. Name it as a Submit and Cancel button as picture below.regisForm








6) Under the On Click Event Procedure of Submit button, enter the code below.

Private Sub cmdSubmit_Click() ' for submit button
On Error GoTo ErrHandler:
If IsNull(UserID) Then
   MsgBox "You have not entered information to submit!", , "No Info"
  ‘check the UserName, LoginID or Password field is not emtry before insert to database
ElseIf IsNull(UserName) Or IsNull(LoginID) Or IsNull(Password) Then
   MsgBox "The Full Name, Login ID and Password fields are required", , "Required Field"
   Msg = "Do you want to submit your registration?"
   Style = vbYesNo + vbCritical
   Title = "Registration Confirmed"
   Response = MsgBox(Msg, Style, Title)
   If Response = vbYes Then
     ‘Submit information and close the registration form
     Exit Sub
   End If
   If Response = vbNo Then
   ‘Cancel submit information and close the registration form
      Exit Sub
    End If
End If
Exit Sub
    MsgBox Err.Description, vbCritical
End Sub

 7) Under the On Click Event Procedure of Cancel button, enter the code below to cancel the entry and close form

Private Sub Command39_Click() ' Cancel button
End Sub

8) Using a DLookup function to check a duplicated name if already exists in the database. Use the VBA code below under the AfterUpdate Event Procedure of UserName field. This prevents users to register their name twice.










Private Sub UserName_AfterUpdate()
Dim NewUser As String
Dim stLinkCriteria As String
NewUser = Me.UserName.Value
stLinkCriteria = "[UserName] = " & "'" & NewUser & "'"
If Me.UserName = DLookup("[UserName]", "tblUser", stLinkCriteria) Then
    MsgBox "This Name, " & NewUser & ", already exists in database." _
    & vbCr & vbCr & "Please check name again Or contact the Administrator", vbInformation, "Duplicate Name"
End If
End Sub

Related Video:

Related posts