[AccessD] FindFirst Error

Gustav Brock gustav at cactus.dk
Wed May 23 13:37:07 CDT 2012


You should use the ISO format(s) for date and time:

yyyy/mm/dd hh:nn:ss

Then this should read:

rstRS.FindFirst "[EmployeeTimesID] = #" & strKey & "#"

Also clean up typos and simplify:

rstRS![EmployeeTimesDate] = DateValue(rstRsNew![Time])
rstRS![EmployeeTimesName] = Trim(rstRsNew![Employee])
rstRS![EmployeeTimesIn] = TimeValue(rstRsNew![Time])

/gustav


>>> dkalsow at yahoo.com 23-05-12 20:14 >>>
Good Afternoon Everyone,
 
I have the following code that is giving me a Run-time error '3077' Syntax error (missing operator) in expression. on the FindFirst line.  Can anyone see why?  
strkey = 5/21/2012Heather Hanson
 
Is access not liking the space in field?
 
Thanks!
 
Set dbsDB = DBEngine(0)(0)
    Set rstRS = dbsDB.OpenRecordset("tblEmployeeTimes", dbOpenDynaset)
    Set rstRsNew = dbsDB.OpenRecordset("qryKeyCardImport", dbOpenDynaset)
    
    rstRsNew.MoveFirst
    
    Do While Not rstRsNew.EOF
        strKey = Format(rstRsNew![Time], "Short Date") & 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] = Format(rstRsNew![Time], "Short Date")
                    rstRS![[EmployeeTimesName]] = Trim(rstRsNew![Employee])
                    rstRS![EmployeeTimesIn] = Format(rstRsNew![Time], "Medium Time")
                    .Update
                  End With
            End If
            rstRsNew.MoveNext
            
        Loop
--



More information about the AccessD mailing list