Gustav Brock
gustav at cactus.dk
Wed May 23 14:44:09 CDT 2012
If strings, it should read: rstRS.FindFirst "[EmployeeTimesID] = '" & strKey &"'" /gustav >>> dkalsow at yahoo.com 23-05-12 21:16 >>> No matter what I try I still get an error on the findfirst command the second time around. I get an error if the # are there or if they are not. I have even taken the slashes out of the date, but it has not helped. Here is the current format of the key: 5212012HeatherHanson Here is the current code: Set dbsDB = DBEngine(0)(0) 'Set db = CurrentDb - Can substitue for above line but slower and will not handle linked files. ' Open database Set rstRS = dbsDB.OpenRecordset("tblEmployeeTimes", dbOpenDynaset) Set rstRsNew = dbsDB.OpenRecordset("qryKeyCardImport", dbOpenDynaset) rstRsNew.MoveFirst Do While Not rstRsNew.EOF strKey = Replace(Format(rstRsNew![Time], "Short Date"), "/", "") & Replace(Trim(rstRsNew![Employee]), " ", "") rstRS.FindFirst "[EmployeeTimesID] = " & strKey If Not rstRS.NoMatch Then With rstRS .Edit rstRS![EmployeeTimesOut] = Format(rstRsNew![Time], "Medium Time") .Update End With Else With rstRS .AddNew rstRS![EmployeeTimesID] = strKey rstRS![EmployeeTimesDate] = DateValue(rstRsNew![Time]) rstRS![EmployeeTimesName] = Trim(rstRsNew![Employee]) rstRS![EmployeeTimesIn] = TimeValue(rstRsNew![Time]) .Update End With End If rstRsNew.MoveNext Loop varTmp = SysCmd(acSysCmdClearStatus) MsgBox "The EmployeeTimes file has been updated", vbOKOnly + vbInformation, "Parts Master" rstRS.Close rstRsNew.Close dbsDB.Close Set rstRS = Nothing Set rstRsNew = Nothing Set dbsDB = Nothing ________________________________ From: Gustav Brock <gustav at cactus.dk> To: accessd at databaseadvisors.com Sent: Wednesday, May 23, 2012 1:57 PM Subject: Re: [AccessD] FindFirst Error Ouch, dates as strings ... Still, this has to be corrected: rstRS![[EmployeeTimesName]] /gustav