.Findfirst Action w/the Date() function

ajetrumpet

Banned
Local time
Today, 07:16
Joined
Jun 22, 2007
Messages
5,638
I'm trying to use FindFirst to look up the current date in my "workdate" field. The find method works, but the program is not reacting correctly to the .NoMatch property after that line. Here is the code:
Code:
    .FindFirst ("[workdate] = " & Date)

      If [COLOR="Red"].NoMatch = True[/COLOR] Then[COLOR="Red"] <--- This is being executed, even if there is a 
                                     matching record found.[/COLOR]

        .AddNew
          !workdate = Date
          !timein = Time()
        .Update

      Else
        
        For i = 1 To rs.Fields.Count - 1
          
          If IsNull(.Fields(i)) Then
            .Edit
              .Fields(i) = Time()
                .Update
                  Exit For
          End If
I'm stuck! Help! Someone please give me a boost! :)
 
Last edited:
Your working example is surrounded by #, the failing versions are not.
 
Paul,

look at my updated post. I just finished correcting it. The # signs have nothing to do it (I don't think anyway).
 
Well, I've got at least a half-bottle of wine in me right now, and I don't normally use FindFirst or NoMatch, but I think you need the # with a date value. I typically use an SQL statement that only returns the relevant record(s). Plus it's no fair changing the original post to something completely different than what was there before, particularly when I'm half-baked. :D

If that doesn't sort it, how about a sample db?
 
You definitely need the # marks. Make it this:

.FindFirst ("[workdate] = #" & Date & "#")

And Paul, was there a sale on Boone's Farm? ;)

(I'm a six pack in myself... lol...)
 
You win Moniker, thanks.

You would think I would have used the Date function like this before, but: NOPE! I'll mark the rule in my scrapbook.

Sorry Paul... ;) Hope you made it through the night OK....
 
How does he win? I gave you the answer first! :p

I like beer too, but it would take me a while to go through a six pack. I'm a cheap drunk I guess. :D

Thanks Adam, I had a great night. Nice steak, bottle of wine, beautiful wife...life is good!
 

Users who are viewing this thread

Back
Top Bottom