Results 1 to 5 of 5
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    DAO Recordset FindFirst

    I must not be using FindFirst correctly, see snippet of code below.



    Code:
    With rsRegEMAs
    
    bolrsRegEMAs = True
    
    lngEMACount = 0
    intEMAPartCnt = 1
    
    .FindFirst Not IsNull(!EMA)
    
    If Not .NoMatch Then
        lngEMACount = 1
        blah
        blah
        blah
    Else
        Msgbox "no EMAs found blah blah............
    end if
    The current DAO Recordset has many records containing non-Null EMA expressions but "NoMatch" must be true because the Else path is taken. I assume I've used the FindFirst incorrectly?

    I tried putting the option in quotes like .FindFirst "Not IsNull(!EMA)" but runtime then does not recognize the field reference to !EMA.

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    AFAIK, You find first from the underlying domain, not the recordset itself. Check out
    https://docs.microsoft.com/en-us/off...rst-method-dao

    ...the criteria should be in either the form "field = value" where field is an indexed field in the underlying base table,...
    Bold format is by me.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Using the statement:
    Code:
    .FindFirst "!EMA <> Null"
    while satisfying the FindFirst syntax fails because !EMA is not recognized as a field. In the underlying query, EMA is coded as a substitute for "eMail_Address", i.e., EMA:. Further, eMail_Address is not an indexed field.

    Because of other considerations I think I'll just step through the recordset one record at a time and examine the EMA as I go.

  4. #4
    John_G is offline VIP
    Windows 10 Access 2016
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    I tried putting the option in quotes like .FindFirst "Not IsNull(!EMA)" but runtime then does not recognize the field reference to !EMA.
    Try putting the criteria in quotes, but without the "!" :
    .FindFirst "Not IsNull(EMA)"

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Thanks John. After digging a little deeper into the very old app, basic human intelligence prevailed and I just tweaked whatever filter might have been in affect and processed as needed with a clone.

    (Whatever possessed me years ago to name a table field that includes a dash character totally alludes me. Same can be said of "blanks". Including "EMA As e-MailAddr" in a query is okay most of the time, but not everywhere. At the moment, I can't remember the exact context where the EMA reference failed at Runtime.)

    Code:
    Private Sub cmdEMAToCB_Click()
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    ' Unless invoked via the "Selected" UI, the current recordset may or may not have any
    ' EMA's.  With that, we append additional criteria to the existing RecordSource to
    ' exclude records that do not include EMAs.
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    If Me.FilterOn Then      'Applies to both QRegistry AND QGroupings
        Me.Filter = Me.Filter & " AND not isnull(Registry.[e-MailAddr])"
    Else
        Me.Filter = "not isnull(Registry.[e-MailAddr])"
        Me.FilterOn = True
    End If
    Me.Requery
    
    EMAtoCB ("Clone")      'Get full or filtered set (EMAtoCB will now have a clean DOA Recordset to process)
    
    End Sub
    Thanks again,
    Bill

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Recordset FindFirst problems Err:3070
    By CabbyL in forum Programming
    Replies: 3
    Last Post: 08-25-2017, 07:21 PM
  2. Recordset FindFirst
    By Praveenevg in forum Access
    Replies: 1
    Last Post: 08-18-2014, 12:55 PM
  3. recordset .findfirst question
    By RonL in forum Programming
    Replies: 4
    Last Post: 06-22-2013, 01:12 PM
  4. Recordset FindFirst Not Working
    By ShoresJohn in forum Programming
    Replies: 5
    Last Post: 03-01-2012, 06:59 PM
  5. Recordset Findfirst Problem
    By ColPat in forum Programming
    Replies: 6
    Last Post: 07-22-2010, 04:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums