Results 1 to 7 of 7
  1. #1
    kattatonic1 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Location
    Toronto, Canada
    Posts
    77

    Question looking for the text of one field in another

    Hi,



    I want to return the records whose field [strDetails] (a text field) contains the text from the last name field [strLastName]. I have been playing with strComp and inStr and can't seem to hit it.

    Many thanks!

    Kay from chilly Toronto today

  2. #2
    kattatonic1 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Location
    Toronto, Canada
    Posts
    77
    Maybe I should mention that the two fields to compare are in two different tables.

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    What do you have so far? The field is named strDetails?

  4. #4
    kattatonic1 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Location
    Toronto, Canada
    Posts
    77
    In TBL1 the field name is strDetails. It contains contents like "blah blah blah Smith blah". It's a short comment from the HR department.
    In TBL2 the other field is named strLastName. We need to know if the person is mentioned in the comment.
    So need a criteria that means "return just records where the text of strLastName is contained in the text of strDetails".

    Anything I've tried with inStr and strComp have returned no records.

    Thanks for any help!

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    I would go after the info in a form where the User is interacting with the data. I would declare a couple string variables and assign the values of a couple bound controls to the variables.

    dim strText as string
    dim strFind as string

    strText = Me.strDetails
    strfind = Me.strLastName

    if instr(strText, strfind) then
    msgbox "Found Name"
    else
    msgbox "No Match Found"
    end if

  6. #6
    kattatonic1 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Location
    Toronto, Canada
    Posts
    77
    That actually helps with something else I'm doing.

    For this one we are just working on setting up a query that will return the starting data required on certain forms. We haven't started building the forms yet.

  7. #7
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Try creating an alias field in your Query builder with this in the field
    FoundName: instr([TBL1].[strDetails], [TBL2].[strLastName])

    and this in the criteria
    >=1

    You can choose to hide your field

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

Similar Threads

  1. Replies: 4
    Last Post: 10-15-2012, 11:38 AM
  2. Replies: 2
    Last Post: 06-11-2012, 09:37 AM
  3. Replies: 12
    Last Post: 06-04-2012, 10:55 AM
  4. Replies: 2
    Last Post: 05-05-2010, 02:52 PM
  5. Split text field into two text fields
    By Grant in forum Access
    Replies: 6
    Last Post: 01-31-2008, 05:52 AM

Tags for this Thread

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