Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Welcome to the skill header Forums. You can ask questions, get help, or help other members out. Join our Forum for free.
Hi Everyone, I have become a big fan of Skillheader.com and learning through the youtube tutorials how to use MS Access properly and VBA coding ... more a just for fun thing for me but I start to see already positive benefits for my daily work. Anyway, I have an issue with VBA coding and followed the instructions on the video. When it comes to the point "Add New User" and coding the submit button, I always get an Error Message "Variable not Defined". It seems as if the Form frm_NewUser is the not defined variable ... the code is as per attached screenshots. Can somebody help me please and give me some guidance?
Thanks,
Falk
Private Sub btn_Save_Click()
'Check whether all fields are filled in
If IsNull(Me.txt_FirstName) = True Or IsNull(Me.txt_LastName) = True Or IsNull(Me.txt_Username) = True Or IsNull(Me.txt_SelectProfile) = True Or IsNull(Me.txt_Password) = True Or IsNull(Me.txt_ConfirmPassword) = True Or IsNull(Me.txt_Authentification) = True Then
MsgBox "Please enter all fields!", vbExclamation, "Empty Data"
Exit Sub
'Check if both Passwords are matching
ElseIf Me.txt_Password <> Me.txt_ConfirmPassword Then
MsgBox "Password not matching", vbCritical, "Password Error"
Exit Sub
'Check if Password is not longer then 8 characters
ElseIf Len(Me.txt_Password) > 8 Then
MsgBox "Password longer then 8 characters", vbCritical, "Password too Long"
Exit Sub
'Data Entry into tbl_Users
Else
Set frm_NewUser = CurrentDb.OpenRecordset("tbl_Users", dbOpenDynaset, dbSeeChanges)
With frm_NewUser
.AddNew
.Fields("FirstName") = Me.txt_FirstName
.Fields("LastName") = Me.txt_LastName
.Fields("UserName") = Me.txt_Username
.Fields("Password") = Me.txt_Password
.Fields("Status") = "Active"
.Fields("UserDate") = Date
.Fields("ProfileID") = Me.txt_SelectProfile
.Update
End With
Set frm_NewUser = Nothing
'Close form after submission
DoCmd.Close acForm, "frm_NewUser", acSaveYes
MsgBox "Data Successfully Saved", vbInformation, "Data Entry"
End If
It would be of great help if you could tell us what video series you are working on here. Additionally, if you could send a couple screen shots of the NewUser Form: Form & Design Views. This way we all can be on the same page!