+ Reply to Thread
Results 1 to 2 of 2

Loop through fields with identical names and retrieve the value

  1. #1
    Registered User
    Join Date
    08-24-2016
    Location
    Nederlands
    MS-Off Ver
    2010
    Posts
    1

    Loop through fields with identical names and retrieve the value

    I have a userform with 10 nearly identical fields: txtId1, txtId2 ..... txtId10
    I want to retreive the fieldvalue if one is entered.
    I can do this by:

    x = 0
    If frm.txtId1.value <> "" Then
    Redim preserve ids(x) = frm.txtId1.value
    x = x =1
    End if

    If frm.txtId2.value <> "" Then
    Redim preserve ids(x) = frm.txtId2.value
    x = x =1
    End if


    But that is not what I want, I'm lazy and I want to write as little as possible code

    So I thought of

    For x = 1 to 10
    field = "txtId" & x
    Redim preserve ids(x-1) = frm.Getvalue(field)
    Next x


    What is correct for the bold code? This option doesn't work also frm.field.value doesn't work.

    Thank you.

  2. #2
    Valued Forum Contributor abduljaleel.mca's Avatar
    Join Date
    02-13-2013
    Location
    Chennai, India
    MS-Off Ver
    MS 365 Business
    Posts
    326

    Re: Loop through fields with identical names and retrieve the value

    Try:
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Search fields to retrieve Most Recent Date
    By bfs3 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-10-2013, 04:33 PM
  2. Replies: 11
    Last Post: 10-21-2012, 01:40 AM
  3. retrieve multiple cells with identical cell next to it
    By Perkett21 in forum Excel General
    Replies: 7
    Last Post: 02-10-2012, 01:06 PM
  4. How to sum identical names in SQL?
    By jgomez in forum Access Tables & Databases
    Replies: 7
    Last Post: 10-06-2011, 01:26 PM
  5. Removing similar but not identical names
    By dalew in forum Excel General
    Replies: 1
    Last Post: 06-27-2011, 08:44 PM
  6. Charts and entries with identical fields
    By Doctor Klaproth in forum Excel General
    Replies: 1
    Last Post: 06-03-2010, 03:21 PM
  7. Finding identical names across 3 spreadsheets
    By roflcopterpilot in forum Excel General
    Replies: 1
    Last Post: 04-08-2010, 05:10 PM
  8. merge identical fields and generate totals.
    By apeman1977 in forum Excel - New Users/Basics
    Replies: 7
    Last Post: 03-18-2009, 11:30 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1