Consulting

Results 1 to 12 of 12

Thread: Solved: array help

  1. #1

    Solved: array help

    i have a form with text boxes that a user would have to enter information into. i thought of making this a multi-dimensional array but figured that it would be too complicated to search as i'm pretty new to vba and don't know how to do that much.so when the user enters certain information such a surname and first name i want them to be stored in seperate arrays but in the same position. so i guess what i'm asking is how to i combine all these different text boxes which i have different arrays for to store all the information for one person seperately but still together so if i search for it it will come up?

  2. #2
    It would be much better to use an array, and once you've got to grips with them you will find them invaluable....

    First you would need to create the variable:

    [vba]Option Explicit
    Dim ClientName() as variant[/vba]

    Then in your code, you would need to allocate storage space for the array (I find it helps to think of a multi-dimensional array like rows and columns).
    So for example, if you had 10 names, and you wanted to store just the surname and the first name then:

    [vba]ReDim ClientName(10,2)[/vba]

    Then you could store the information from the textboxes into the array, so say your first text box was called "txtSurname1" and the next "txtFirstname1" then:

    [vba]ClientName(1,1) = the value of txtSurname1
    ClientName(1,2) = the value of txtFirstname1[/vba]

    and so on.....

  3. #3
    yeah that's what i'm doing now. sorry if i don't understand your message but how exactly then do i connect all those seperate arrays together?

  4. #4
    Now it's my turn not to understand. What do you mean by
    connect all those seperate arrays together?
    What is it you are trying to do with this information once you've stored it?

  5. #5
    hey! maybe i don't really know how to do this so ill tell you what i want to do. i have a form that a user has to fill in with things like their name, address etc. i want to store all of this information and i want the user to be able to search through this information and be able to open the txt file that it gets stored in (i dont know if there is a function for that though). so thats pretty much what i want done with the data. does that make more sense and less confusion for both of us?

  6. #6
    So you will have 10 forms that 10 different users will have filled in? To help me understand what you are trying to achieve, why would you want user 1 to be able to see what the other 9 had filled in?

  7. #7
    well its just one form that a user enters information of a member and they enter the information in text boxes. then theres another command button that the user can click to search with and they type a certain name and their information would come up. the person using this would be the person who does the data entry for the members

  8. #8
    OK - so you want to be able to utilize the information time and time again? Where are you going to store that information?

  9. #9
    well im going to store the information in a text file and i want it to be able to be retrieved when someone searches for it or want to open the file.

  10. #10
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Why not store the data in a Excel. It's more amenable to searching and returning data.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  11. #11
    yeah it would be great to be able to store the data in excel and do it that way but my specs say that i cannot do that so i have to figure out another way to do it

  12. #12
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    my specs
    Better specs...better code.

    It would possibly help if you actually stated what those specs are.

    Generically, malcolm is quite correct. This should be Excel. Or maybe even Access, since what you describe sounds like the use of a database.

    However, try telling us exactly what you are going to do. You are confusing. You are writing to a text file? You are getting stuff from a text file. OK. What is the format of the text file? Is this text file open? Is it a different file from the Word document you are in? The same file? If it is the same file, then it is not a text file. Straight ASCII text files can not hold VBA code. In fact....what is in the Word document you have this code in?

Posting Permissions

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