I have an excel spreadsheet named Employee with fields Name, DOJ, Salary and State. I want to dump the data into a MS access Temp-EmployeeData table from execl spreadsheet everyday so that I can create a report anytime needed for any date.
I created Temp-EmployeeData table with EmpName as Text type, DateOfJoining as Date type, Salary as Currency and State as Text type.
I am writing a code but it is coping the salary and Date field into the Temp-EmployeeData table from Employee spreadsheet but for Name and State, the error is Item could not be found.
MY Code is :
Dim MyWk_XLS As Workspace, MyDB_XLS As Database, MyTable_XLS As Recordset
Set MyDB_XLS = DBEngine.Workspaces(0).Databases(0)
Set MyTable_XLS = MyDB_XLS.OpenRecordset("Employee")
Dim MyWk_Temp As Workspace, MyDB_Temp As Database, MyTable_Temp As Recordset
Set MyDB_Temp = DBEngine.Workspaces(0).Databases(0)
Set MyTable_Temp = MyDB_Temp.OpenRecordset("Temp-EmployeeData")
'here's logic to fill temp table
MyTable_XLS.MoveFirst
Do Until MyTable_XLS.EOF
MyTable_Temp.AddNew
MyTable_Temp![EmpName] = MyTable_XLS![Name]
MyTable_Temp![DateOfJoining] = MyTable_XLS![DOJ]
MyTable_Temp![Salary] = MyTable_XLS![Salary]
MyTable_Temp![State] = MyTable_XLS![State]
MyTable_Temp.Update
MyTable_XLS.MoveNext
Loop
Thanks,
Blyssz
I created Temp-EmployeeData table with EmpName as Text type, DateOfJoining as Date type, Salary as Currency and State as Text type.
I am writing a code but it is coping the salary and Date field into the Temp-EmployeeData table from Employee spreadsheet but for Name and State, the error is Item could not be found.
MY Code is :
Dim MyWk_XLS As Workspace, MyDB_XLS As Database, MyTable_XLS As Recordset
Set MyDB_XLS = DBEngine.Workspaces(0).Databases(0)
Set MyTable_XLS = MyDB_XLS.OpenRecordset("Employee")
Dim MyWk_Temp As Workspace, MyDB_Temp As Database, MyTable_Temp As Recordset
Set MyDB_Temp = DBEngine.Workspaces(0).Databases(0)
Set MyTable_Temp = MyDB_Temp.OpenRecordset("Temp-EmployeeData")
'here's logic to fill temp table
MyTable_XLS.MoveFirst
Do Until MyTable_XLS.EOF
MyTable_Temp.AddNew
MyTable_Temp![EmpName] = MyTable_XLS![Name]
MyTable_Temp![DateOfJoining] = MyTable_XLS![DOJ]
MyTable_Temp![Salary] = MyTable_XLS![Salary]
MyTable_Temp![State] = MyTable_XLS![State]
MyTable_Temp.Update
MyTable_XLS.MoveNext
Loop
Thanks,
Blyssz