[AccessD] FindFirst Error

Rocky Smolin rockysmolin at bchacc.com
Wed May 23 14:35:26 CDT 2012


Right before the findfirst put MsgBox "*" & strKey & "*".

I'll bet you see something the second time around that you don't see the
first time.

Also, I'm reading it more carefully now - # is the wrong way to delimit it -
it's a date plus a name so try delimiting your strkey with apostrophes -
strkey = "'" & strkey & "'"

Rocky
 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Dale Kalsow
Sent: Wednesday, May 23, 2012 12:16 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] FindFirst Error

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


>>> dkalsow at yahoo.com 23-05-12 20:30 >>>
The entire field is defined as a string in the table.  Also, the first time
around (when the table is empty) the first record is created without an
error.

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list