FindFirst syntax 2.0 to 97 ? 
Author Message
 FindFirst syntax 2.0 to 97 ?

After a crash course in DAOs, it seems like only the following two* lines
are failing in my module.

Set RS = DB.OpenRecordset("qryTimeClockDay")
*  RS.FindFirst "employed=" + GetEmployeeID(UserID) + "AND IsNull(Time_Out)"
*  If RS.NoMatch Then....
 (employed, example 91, was found during a previous jump to function
GetEmployeeID; qryTimeClockDay doesn't contain a UserID & does contain a
Time_Out)

Should the (UserID) be a value I can try to display?
Everything after the above lines* work when they are commented out.  I can't
find
a similar enough example to help me.  Examples of NoMatch like
(blank).NoMatch, fail,
Could the FindFirst problem be with the  AND?, the +'s?,  should I use &'s?
This code worked perfect in 2.0, not in Jet 3.5.
Thanks in advance for your time.
Sid



Sat, 14 May 2005 23:18:31 GMT  
 FindFirst syntax 2.0 to 97 ?
After a crash course in DAOs, it seems like only the following two* lines
are failing in my module.

 Set RS = DB.OpenRecordset("qryTimeClockDay")
 *  RS.FindFirst "EmployeeID=" + GetEmployeeID(UserID) + "AND
IsNull(Time_Out)"
 *  If RS.NoMatch Then....
  (EmployeeID, example 91 (was found during a previous jump to function
 GetEmployeeID); qryTimeClockDay doesn't contain a field UserID & does
contain a
 Time_Out)

 Should the (UserID) be a value I can try to display?
 Everything after the above lines* work when they are commented out.  I
can't
 find
 a similar enough example to help me.  Examples of NoMatch like
 (blank).NoMatch, fail,
 Could the FindFirst problem be with the  AND?, the +'s?,  should I use &'s?
 This code worked perfect in 2.0, not in Jet 3.5.
 Thanks in advance for your time.
 Sid



Sun, 15 May 2005 00:33:44 GMT  
 FindFirst syntax 2.0 to 97 ?
On Tue, 26 Nov 2002 09:18:31 -0600, "97 User"

Quote:

>After a crash course in DAOs, it seems like only the following two* lines
>are failing in my module.

>Set RS = DB.OpenRecordset("qryTimeClockDay")
>*  RS.FindFirst "employed=" + GetEmployeeID(UserID) + "AND IsNull(Time_Out)"
>*  If RS.NoMatch Then....
> (employed, example 91, was found during a previous jump to function
>GetEmployeeID; qryTimeClockDay doesn't contain a UserID & does contain a
>Time_Out)

You're missing a blank. If the function returns 91 this query string
will be

employed = 91AND IsNull(Time_Out)

91AND is, of course, nonsensical to Access.

Also, in a Query, you should probably use the IS NULL operator rather
than the IsNull() function: try

RS.FindFirst "employed=" + GetEmployeeID(UserID) + " AND Time_Out IS
NULL"

in order to find those records where [Employed] - a Number field -
contains the numeric value returned by the function and where the
Time_Out field contains nothing. (If that's not what you're trying to
find post back!)

I'm not at all certain what you're trying to find here.

Quote:
>Should the (UserID) be a value I can try to display?

Yes. It needs to be a text string to build the SQL; it should
correspond to a legitimate value in the field [Employed]. If
GetEmployeeId returns a null or empty string, you'll need to trap that
event - perhaps the function should be written to return 0 or some
other value that never corresponds to a real record.

Quote:
>Everything after the above lines* work when they are commented out.  I can't
>find
>a similar enough example to help me.  Examples of NoMatch like
>(blank).NoMatch, fail,

NoMatch is a property of a Recordset object. It's True if the
recordset has no data, False if there is data. I'm not sure what you
mean by the previous sentence.

Quote:
>Could the FindFirst problem be with the  AND?, the +'s?,  should I use &'s?
>This code worked perfect in 2.0, not in Jet 3.5.

I'm sorry, but I think the code has gotten garbled in between. This
could never have worked, not as you have posted it!

                  John W. Vinson[MVP]    
    Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public



Sun, 15 May 2005 02:33:03 GMT  
 FindFirst syntax 2.0 to 97 ?


Quote:
> Set RS = DB.OpenRecordset("qryTimeClockDay")
>  *  RS.FindFirst "EmployeeID=" + GetEmployeeID(UserID) + "AND
> IsNull(Time_Out)"
>  *  If RS.NoMatch Then....

You've already had the answer to this above.

Expanding the search string you get something like

  "EmployeeID=20954AND IsNull(Time_Out)"

and the error is obvious.

By the way, the & operator is recommended for string concatenation (that's
what you are doing here) because (a) + will produce a data type error if
you mix data types (it will try to add rather than concatenate if one of
them is a number), and (b) it will return NULL if one of the components is
null.

HTH

Tim F



Sun, 15 May 2005 02:45:47 GMT  
 FindFirst syntax 2.0 to 97 ?
John
WOW, It works!!
Excuse the error in my initial post, (spell checker) it should have been:
 RS.FindFirst "EmployeeID=" + GetEmployeeID(UserID) + "AND IsNull(Time_Out)"

all morning and found that noone uses + signs, instead &.  It worked.  Now
it is as follows:
RS.FindFirst "EmployeeID=" & GetEmployeeID(UserID) & " AND Time_Out IS NULL"
Thanks for your time.
Sid


Quote:
> On Tue, 26 Nov 2002 09:18:31 -0600, "97 User"

> >After a crash course in DAOs, it seems like only the following two* lines
> >are failing in my module.

> >Set RS = DB.OpenRecordset("qryTimeClockDay")
> >*  RS.FindFirst "employed=" + GetEmployeeID(UserID) + "AND
IsNull(Time_Out)"
> >*  If RS.NoMatch Then....
> > (employed, example 91, was found during a previous jump to function
> >GetEmployeeID; qryTimeClockDay doesn't contain a UserID & does contain a
> >Time_Out)

> You're missing a blank. If the function returns 91 this query string
> will be

> employed = 91AND IsNull(Time_Out)

> 91AND is, of course, nonsensical to Access.

> Also, in a Query, you should probably use the IS NULL operator rather
> than the IsNull() function: try

> RS.FindFirst "employed=" + GetEmployeeID(UserID) + " AND Time_Out IS
> NULL"

> in order to find those records where [Employed] - a Number field -
> contains the numeric value returned by the function and where the
> Time_Out field contains nothing. (If that's not what you're trying to
> find post back!)

> I'm not at all certain what you're trying to find here.

> >Should the (UserID) be a value I can try to display?

> Yes. It needs to be a text string to build the SQL; it should
> correspond to a legitimate value in the field [Employed]. If
> GetEmployeeId returns a null or empty string, you'll need to trap that
> event - perhaps the function should be written to return 0 or some
> other value that never corresponds to a real record.

> >Everything after the above lines* work when they are commented out.  I
can't
> >find
> >a similar enough example to help me.  Examples of NoMatch like
> >(blank).NoMatch, fail,

> NoMatch is a property of a Recordset object. It's True if the
> recordset has no data, False if there is data. I'm not sure what you
> mean by the previous sentence.

> >Could the FindFirst problem be with the  AND?, the +'s?,  should I use
&'s?
> >This code worked perfect in 2.0, not in Jet 3.5.

> I'm sorry, but I think the code has gotten garbled in between. This
> could never have worked, not as you have posted it!

>                   John W. Vinson[MVP]
>     Come for live chats every Tuesday and Thursday
> http://go.compuserve.com/msdevapps?loc=us&access=public



Sun, 15 May 2005 05:08:14 GMT  
 FindFirst syntax 2.0 to 97 ?
On Tue, 26 Nov 2002 15:08:14 -0600, "97 User"

Quote:

>John
>WOW, It works!!
>Excuse the error in my initial post, (spell checker) it should have been:
> RS.FindFirst "EmployeeID=" + GetEmployeeID(UserID) + "AND IsNull(Time_Out)"

>all morning and found that noone uses + signs, instead &.  It worked.  Now
>it is as follows:
>RS.FindFirst "EmployeeID=" & GetEmployeeID(UserID) & " AND Time_Out IS NULL"
>Thanks for your time.

The problem, as I and at least one other person pointed out, was NOT
the plus sign. Both + and & concatenate strings.

The problem was that you had a missing blank. The code that didn't
work had

"AND ...

whereas the code that did work (above) has

" AND ...

Blanks ARE MEANINGFUL to computers. Leaving them out when they're
needed will cause problems!

                  John W. Vinson[MVP]    
    Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public



Sun, 15 May 2005 08:01:53 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Access 97 FindFirst

2. Syntax error in FindFirst criteria

3. rst.FindFirst criteria - Syntax Error !!!!

4. Access95 FindFirst Syntax Error

5. rst.FindFirst criteria - Syntax Error !!!!

6. Syntax Error Assining date value to FindFirst

7. Syntax Error Assigning date value to FindFirst

8. Q: Reference variable in FindFirst syntax?

9. FindFirst Method syntax

10. FindFirst method syntax (?)

11. SQL syntax in FindFirst statements.

12. SQL syntax in FindFirst Statement

 

 
Powered by phpBB® Forum Software