Results 1 to 3 of 3
  1. #1
    john60 is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    1

    Question can not use FindRecord with string

    i can get this to work
    DoCmd.FindRecord "hello",,True,,True,AcAll
    but not this
    dim b As String


    b="hello"
    DoCmd.FindRecord b,,True,,True,AcAll
    or again not this
    Me!textbox9="hello"
    DoCmd.FindRecord Me!textbox9,,True,,True,AcAll
    can any one help please

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Shot in the dark, but try

    DoCmd.FindRecord "'" & Me!textbox9 & "'",,True,,True,AcAll
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    As I said in your other post on this problem, I have no trouble with your second example, using the variable B. I've gnawed at this for a while, and got it to do what I'm telling it to, finding the Record with the textbox9 value. The problem with using a Textbox for this code is that the Access Gnomes are always going to find that value in the textbox9 on the Current Record! It's not going to go to another Record!

    Rather than using a Textbox to enter the value, I'd use a Command Button together with the Inputbox Function, something like this:

    Code:
    Private Sub btnSearch_Click()
    
    Dim SearchTerm As String
     
     SearchTerm = InputBox("Please Enter Search Term")
    
     DoCmd.FindRecord SearchTerm, , True, , True, acAll
    
    End Sub

    This appears to answer your needs.

    Linq ;0)>

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

Similar Threads

  1. String
    By Rhubie in forum Queries
    Replies: 1
    Last Post: 05-28-2013, 09:15 PM
  2. Vba string
    By rchtan in forum Programming
    Replies: 5
    Last Post: 05-17-2012, 04:29 AM
  3. Filter or FindRecord in Split Form
    By P5C768 in forum Forms
    Replies: 4
    Last Post: 03-20-2012, 12:16 PM
  4. SQL + VBA String
    By jgelpi16 in forum Programming
    Replies: 2
    Last Post: 08-22-2011, 08:44 AM
  5. Can you use a parameter in findrecord?
    By P5C768 in forum Programming
    Replies: 2
    Last Post: 08-20-2009, 04:36 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