Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8453459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:46:47+00:00 2026-06-10T11:46:47+00:00

Using VBA, how can I search for a text string, for example CHIR ,

  • 0

Using VBA, how can I search for a text string, for example “CHIR”, in a table called “ServiceYES”, in the field “Service”.

After that, I would like to save the neighboring field for all the rows that “CHIR” exists in the table “ServicesYES”. The “ServiceYES” table is below:

ServiceYES table

I basically, want to find all the “CHIR” in “Service” column and then save the names which are on the left of the CHIR, eg “FRANKL_L”, “SANTIA_D” as an array.

Thanks for all your help in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:46:49+00:00Added an answer on June 10, 2026 at 11:46 am

    Start by creating a SELECT query.

    SELECT Code_Perso
    FROM ServicesYES
    WHERE Service = 'CHIR';
    

    Use SELECT DISTINCT Code_Perso if you want only the unique values.

    Add ORDER BY Code_Perso if you care to have them sorted alphabetically.

    Once you have a satisfactory query, open a DAO recordset based on that query, and loop through the Code_Perso values it returns.

    You don’t need to load them directly into your final array. It might be easier to add them to a comma-separated string. Afterward you can use the Split() function (assuming you have Access version >= 2000) to create your array.

    Here’s sample code to get you started. It’s mostly standard boiler-plate, but it might actually work … once you give it “yourquery”.

    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim strItems As String
    Dim varItems As Variant
    Set db = CurrentDb
    Set rs = db.OpenRecordset("yourquery", dbOpenSnapshot)
    With rs
        Do While Not .EOF
            strItems = strItems & "," & !Code_Perso
            .MoveNext
        Loop
        .Close
    End With
    If Len(strItems) > 0 Then
        ' discard leading comma '
        strItems = Mid(strItems, 2)
        varItems = Split(strItems, ",")
    Else
        MsgBox "Oops.  No matching rows found."
    End If
    Set rs = Nothing
    Set db = Nothing
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using VBA to create a FileOpenDialog object so that the user can select
Using VBA, can I find out the value of a text (combobox) control on
Does anyone know how to clear the immediate window using VBA? While I can
I would like to know if using VBA I can compare two similar excel
How can I execute FCIV and obtain a hash for a file using VBA?
Is there a way I can run regsvr32.exe to register a dll using VBA?
The following Visio macro (using VBA) rotates the currently selected shape: ActiveWindow.Selection.Rotate90 How can
I'm using VBA to do some further formatting to a generated CSV file that's
Can i export a data from a table to an excel sheet, using javascript?
Did I understood correctly that you can't subscribe to an event other than using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.