Run Time Error 13: Type Mismatch (1 Viewer)

MS_Access_Amature

Registered User.
Local time
Today, 01:34
Joined
Nov 10, 2010
Messages
56
Im creating a punch in punch out system.

I have 3 tables: UsersT(Where the name of all the employees are), EmployeesT(Where the data from that day is stored, punch in and out time), TimeSheetT(Where all the data is and only the administrator can go inn and change).

In the form i have a listbox that brings up the employees names from the usersT. A ButtonPunchIn and a ButtonPunchOut.

My code for when I click ButtonClockIn is giving me a type mismatch error. Can someone please take a look and see if they can see the problem. They debugger stop me at : strMyValue = Me.listEmployee

Private Sub ButtonPunchIn_Click()
Dim db As DAO.Database, strMyValue As Long, datMyValue2 As Date, datMyValue3 As Date
strMyValue = Me.listEmployee
datMyValue2 = Date
datMyValue3 = Now()
Set db = CurrentDb
db.Execute "Insert into Employee (EmployeeName, DateOfWork, TimeIn) VALUES ('" & strMyValue & "',#" & datMyValue2 & "#,#" & datMyValue3 & "# )"
Set db = Nothing
End Sub
 

boblarson

Smeghead
Local time
Today, 01:34
Joined
Jan 12, 2001
Messages
32,059
You have strMyValue set as a LONG but are trying to put it into the Employee NAME field as a string.

1. You should be storing the ID (which is why you have the long and why you are using the bound column of the listbox I'm sure).

2. So, your field that should be getting the update is not employee name but employee ID.
 

MS_Access_Amature

Registered User.
Local time
Today, 01:34
Joined
Nov 10, 2010
Messages
56
yupp...it worked!! all i had to do was change As Long to As String.


THANK YOU!!!
 

Users who are viewing this thread

Top Bottom