[AccessD] FindFirst Error

Darryl Collins darryl at whittleconsulting.com.au
Wed May 23 19:22:19 CDT 2012


Thanks guys... "Wrong" was the 'wrong' word and also a bit harsh (didn't mean to sound like a cretin or smart arse)

I should have said - 'unnecessary' instead....



-----Original Message-----
From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Jim Lawrence
Sent: Thursday, 24 May 2012 9:56 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] FindFirst Error

Hardly wrong, but verbose to the point of asking why use the WITH structure.

Jim

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

Hi Dale,

On another issue: The following bit of code

	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

Is wrong - it probably works, as VBA is very forgiving, but try using

	With rstRS
                    .AddNew
                    ![EmployeeTimesID] = strKey
                    ![EmployeeTimesDate] = Format(rstRsNew![Time], "Short
Date")
                    ![[EmployeeTimesName]] = Trim(rstRsNew![Employee])
                    ![EmployeeTimesIn] = Format(rstRsNew![Time], "Medium
Time")
                    .Update
                  End With

Instead.  If nothing else will be faster.  Either that or drop the with/end with.

Cheer
Darryl.



-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Dale Kalsow
Sent: Thursday, 24 May 2012 4:14 AM
To: Access Developers discussion and problem solving
Subject: [AccessD] FindFirst Error

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
--
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


-- 
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