Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    New Jersey, USA
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    array (97 access vba)

    I have a text field that contains names that are separated with a ",". I want to put this field into an array so I can print the data out of the field separately. I know this is a very bad design but I inherited this problem. To make it worse not all of the records have this type of data in the field. Some just have a single name.

    Is it possible to do this.
    thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: array (97 access vba)

    - Do you mean that you want to split the field into several fields? If the number of names varies, that can be problematic.
    - Another way could be to create a separate table linked to the main table, with a separate record for each name.
    - If you really meant an array, how would you use it?

  3. #3
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    New Jersey, USA
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: array (97 access vba)

    My thoughts have been on arrays, maybe that is the wrong way to think of it. The data in the field is a mess and all I really want to do is seperate it out and print it separately.
    example - same field on each record
    record 1 - john smith, mary smith, joe smith
    record 2- Peter Jones
    record 3- Sara Johnson, Bill Thomas

    I want to print out 6 lines one name on each line.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: array (97 access vba)

    I have attached a zipped database that demonstrates a possible approach. The table tblNames contains the sample names from your post, plus an autonumber field ID. There is also an empty table tblSingleNames with a number field ID and a text field SingleName.
    The module basCode contains a procedure SplitNames. If you run it, it will read tblNames and use it to populate tblSingleNames. The end result will be 6 names in 6 separate records.

    See if you can adapt the code for your situation.

  5. #5
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    New Jersey, USA
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: array (97 access vba)

    Thanks I think this will work

Posting Permissions

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