whats wrong to my code all I want is to update table using Name and Pin of the Employee on their corresponding ID but any pin is accessible to the other Employee please help me!
Dim CanteenPOS As DAO.Database
Dim tblEmployee As DAO.Recordset
Set CanteenPOS = CurrentDb
Dim ID As Integer
If IsNull(Me.txtName) Or IsNull(Me.txtPin) Then
MsgBox "First! Please enter your EmployeeID before PinID", vbInformation
Me.txtName.SetFocus
Else
If (IsNull(DLookup("EmployeeID", "tblEmployeeID", "EmployeeID = '" & Me.txtName & "'"))) Or _
(IsNull(DLookup("PinID", "tblEmployeeID", " PinID = '" & Me.txtPin & "'"))) Then
MsgBox "Invalid EmployeeID or PinID!"
Else
Me.txtUsername = DLookup("[EmployeeID]", "tblEmployeeID", "[EmployeeID] = '" & Me.txtName.Value & "'")
Me.txtPin = DLookup("[PinID]", "tblEmployeeID", " [EmployeeID] = '" & Me.txtName.Value & "'")
MsgBox ("Your transaction is completed!")
Set tblEmployee = CanteenPOS.OpenRecordset("tblEmployee")
tblEmployee.AddNew
tblEmployee("EmployeeName").Value = Me.txtName
tblEmployee("OrderName").Value = Me.txtOrderType
tblEmployee("Price").Value = Me.txtprice
tblEmployee("Datetime").Value = lblDate.Caption
tblEmployee("AddOn").Value = Me.txtAdd
tblEmployee.Update
End If
End If
any pin is accessible to the other Employee. You need to specify what you want to happen and what is happening. And if there are any error messages, please include the error number, full error message, and indicate which line of code the error occurs on. Please see How to Ask."[EmployeeID] = '" &which is not correct for either name or PIN. Besides, you should store the previous values in variables so you don't have to call DLookup redundantly. (Besides that, you seemed concerned that an employee could use another employee's PIN. If you are really concerned about security, Access is really a poor choice of database since any user can probably open the database and find all names and PINS... since it is apparent that you store the PIN as plain text.)