Results 1 to 2 of 2
  1. #1
    Praveenevg is offline Novice
    Windows 8 Access 2007
    Join Date
    Aug 2014
    Posts
    18

    Recordset FindFirst

    Hello,



    Is there a way to use a variable to define the value of the field in FindFirst?


    Set GNRC = CurrentDb.OpenRecordset(strSQL)

    GNRC.FindFirst "FIELD1 = FIELDVALUE"

    How can we pass the FEILDVALUE dynamically? Can we pass a variable to FindFirst?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    Certainly, concatenate variables. Variable can be a declared object in VBA or reference to a control on form.

    GNRC.FindFirst "FIELD1=" & MyVariable

    If FIELD1 is text, use apostrophe delimiters, dates use #.

    GNRC.FindFirst "FIELD1='" & MyVariable & "'"

    GNRC.FindFirst "FIELD1=#" & MyVariable & "#"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 7
    Last Post: 09-28-2023, 08:41 AM
  2. Replies: 4
    Last Post: 12-09-2013, 01:27 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