So i did a little research on recordsets and tried to get my code to put a new record in for a new user. The form has 4 fields that input and 2 that are a access check. The code basically checks if the desired password and confirmed password are the same.. if the admin and password are in the database and if they are correct and then does a message box confiming the creation. These all work fine but my problem is now trying to put a new entry in. here is what i have so far:
Private Sub Command10_Click()
Dim adminPwd As String
Dim valSelect As Variant, MyDB As DAO.Database, MyRS As DAO.Recordset
If DCount("[EmployeeName]", "tblEmployeeId", "[Employeename]='" & Me.AdminUN & "'") > 0 Then
adminPwd = DLookup("[Emp_Password]", "tblEmployeeId", "[Employeename]='" & Me.AdminUN & "'")
If "'" & adminPwd & "'" = "'" & Me.adminPwd & "'" Then
If IsNull(Me.DPwd) = False And IsNull(Me.Cpwd) = False Then
If "'" & Me.DPwd & "'" = "'" & Me.Cpwd & "'" Then
If MsgBox("Are you sure you want to create this account?" & vbCrLf & _
"Please make sure to set the User Access Level", vbQuestion + vbYesNo, "Cancel Confirmation") = vbYes Then
Set MyDB = CurrentDb()
Set MyRS = MyDB.OpenRecordset("tblEmployeeId", dbOpenDynaset)
MyRS.MoveFirst
MyRS.AddNew
MyRS![EmployeeName] = Me.userName
MyRS![Emp_Password] = Me.DPwd
MyRS![Emp_ULaccess] = Me.DULA
MyRS.Update
MyRS.Close
Set MyRS = Nothing
End If
End If
End If
End If
End If
End Sub
Private Sub Command10_Click()
Dim adminPwd As String
Dim valSelect As Variant, MyDB As DAO.Database, MyRS As DAO.Recordset
If DCount("[EmployeeName]", "tblEmployeeId", "[Employeename]='" & Me.AdminUN & "'") > 0 Then
adminPwd = DLookup("[Emp_Password]", "tblEmployeeId", "[Employeename]='" & Me.AdminUN & "'")
If "'" & adminPwd & "'" = "'" & Me.adminPwd & "'" Then
If IsNull(Me.DPwd) = False And IsNull(Me.Cpwd) = False Then
If "'" & Me.DPwd & "'" = "'" & Me.Cpwd & "'" Then
If MsgBox("Are you sure you want to create this account?" & vbCrLf & _
"Please make sure to set the User Access Level", vbQuestion + vbYesNo, "Cancel Confirmation") = vbYes Then
Set MyDB = CurrentDb()
Set MyRS = MyDB.OpenRecordset("tblEmployeeId", dbOpenDynaset)
MyRS.MoveFirst
MyRS.AddNew
MyRS![EmployeeName] = Me.userName
MyRS![Emp_Password] = Me.DPwd
MyRS![Emp_ULaccess] = Me.DULA
MyRS.Update
MyRS.Close
Set MyRS = Nothing
End If
End If
End If
End If
End If
End Sub