Results 1 to 5 of 5

Thread: How to use array in visual basics database development

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2002
    Location
    Here but not there
    Posts
    3

    Question How to use array in visual basics database development

    Hi all..

    Here’s what I wanted to do…

    I have a list of hobby for a particular person.

    TxtHobby1
    TxtHobby2
    TxtHobby3


    So I wanted to represent the above problem with array.. will it be possible?

    Previously here’s what I do…

    With rsUpdFamily

    !hobby1 = frmFamily!txtHobby1.Text
    !hobby2 = frmFamily!txtHobby2.Text
    !hobby3 = frmFamily!txtHobby3.Text
    End With
    rsUpdFamily.Update


    at the same time… my access table also will have the same field name to store all those data.
    Hobby1 as text
    Hobby2 as text
    Hobby3 as text

    Is there any simpler ways to do that?

    I don’t want to do all those if I have around 12 hobbies, so using array is a simpler solution but I have no idea on how to use it properly in Database environment.



    thanks for all the help..
    if need better clarification don't hesitate to ask me again..

    kuman
    Arghhh... runtime error!!

  2. #2
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951
    I don't think there is any way that you can create an array within an ACCESS db. I think what you are doing is how it has to be done.

  3. #3
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    Well, there is a kludge to do this.

    First, let it be said that having "repeating items" (the equivalent of an array) is a "no-no" in relational database design, but that's another issue.

    To do what you want to do, you can use part of the name of the database field as the array "index" - so the fact that you have "Hobby1", "Hobby2", etc. as your field names will help you here.

    Furthermore, in standard VB (not .NET), you have control arrays, so you can rename your textboxes simply "txtHobby", and assign Index values of 1 to 12 respectively.

    Assuming the above is in place, here's some code you can use:
    VB Code:
    1. Dim intX As Integer
    2. With rsUpdFamily
    3.     For intX = 1 To 12
    4.         [b].Fields("hobby" & intX)[/b] = frmFamily!txtHobby[b](intX)[/b].Text
    5.    Next
    6.    rsUpdFamily.Update
    7. End With

    Have fun ...
    "It's cold gin time again ..."

    Check out my website here.

  4. #4

    Thread Starter
    New Member
    Join Date
    Nov 2002
    Location
    Here but not there
    Posts
    3

    THANKS A bundle

    BRUCEG


    thanks a bundle... your solution is what i've been looking for..

    now my coding is a bit short and readable. glad that i ask it here...

    adding to that i have a nother questions that i did post in here early on but no one seems to know how to do it... i thought i ask you instead... just follow the link to my earlier post in this forums..

    HOW TO PUT PICTURE IN OUR VB PROJECT.

    thanks.. any help is much appreciated..

    thanks..
    Arghhh... runtime error!!

  5. #5
    Member
    Join Date
    Feb 2003
    Location
    New Delhi, India
    Posts
    63
    Hi Kumar,

    i have a view of your various questions:

    answer to Question 1 : [picture in database]
    For SQL you can use Textcopy.exe + ntwdblib.dll
    or
    For access you can use OLE Automation (use embed)


    answer to Question 2 : [datatype]
    use "OLE Object" for msaccess and "image" for sql


    well, got to go... will write to you soon..
    can always contact me at [email protected]
    "please mention FROM VBFORUMS in the subject"

Posting Permissions

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



Click Here to Expand Forum to Full Width