CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Join Date
    Nov 2005
    Posts
    11

    edit textbox control array

    hi! im new here and i need some of your knowledge about database and vb 6. im using MS Access. i always get an error on editing a textbox control array? does any one knows how to code the textbox control array? thanks

  2. #2
    Join Date
    Nov 2005
    Posts
    14

    Re: edit textbox control array

    what do you mean dynamically create a text box? elaborate more on the problem please also your code (the code where you had an error) will make it easy for us to help you

  3. #3
    Join Date
    Nov 2005
    Posts
    11

    Re: edit textbox control array

    here is my program..
    Attached Files Attached Files

  4. #4
    Join Date
    Nov 2005
    Posts
    14

    Re: edit textbox control array

    you dont need an array of textboxes to update a database, you can use a listview to view all the data then you can select each item then display it on a textbox to edit..

    here's an example of a listview on click event

    Private Sub ListVw_ItemClick(ByVal Item As MSComctlLib.ListItem)
    dim LS as Listview
    Set LS = ListVw.ListItems.Item(1)
    txtClientID = Item
    txtLoanAccount = Item.SubItems(1)
    txtname = Item.SubItems(2)
    txtAddress1 = Item.SubItems(3)
    txtAddress2 = Item.SubItems(4)
    txtAddress3 = Item.SubItems(5)
    End Sub

  5. #5
    Join Date
    Nov 2005
    Posts
    11

    Re: edit textbox control array

    ok. how do i code it when i want to save it again?

  6. #6
    Join Date
    Nov 2005
    Posts
    14

    Re: edit textbox control array

    CNN.Execute "INSERT into inquiry" & _
    " (CLIENTID, LOANACCOUNTNUMBER, CLIENTNAME)" & _
    " VALUES ('" & txtClientID & "'," & _
    " '" & txtLoanAccount & "'," & _
    " '" & txtname & "')"

  7. #7
    Join Date
    Nov 2005
    Posts
    14

    Re: edit textbox control array

    by the way if you later come across an array you can use For loop to make it easy for the program also to make your code neat

  8. #8
    Join Date
    Nov 2005
    Posts
    11

    Re: edit textbox control array

    hi! olocin, i got index out of bounds error

  9. #9
    Join Date
    Nov 2005
    Posts
    14

    Re: edit textbox control array

    post the code, to where the error occurs

  10. #10
    Join Date
    Nov 2005
    Posts
    11

    Re: edit textbox control array

    hi! olocin this is the code:

    Private Sub Listview1_ItemClick(ByVal Item As MSComctlLib.ListItem)
    Dim LS As ListView
    Set LS = Listview1.ListItems.Item(1) <-----Type mismatch---pointing here
    txtEdit = Item
    txtEdit = Item.SubItems(0)

    Call bind
    End Sub

    ======
    if i place 1 with 0 the error is Index out of bounds
    Last edited by sangkay; December 1st, 2005 at 04:20 AM.

  11. #11
    Join Date
    Dec 2002
    Location
    London, UK
    Posts
    1,569

    Re: edit textbox control array

    Your problem is...

    LS is defined as a ListView.
    ListView1.ListItems.Item(1) however is a ListItem.

    So you can't equate the two. You need to modify the code to be as follows:

    Code:
    Private Sub Listview1_ItemClick(ByVal Item As MSComctlLib.ListItem)
    Dim LS As ListItem
    Set LS = Listview1.ListItems.Item(1)
    txtEdit = Item
    txtEdit = Item.SubItems(0)
    
    Call bind
    End Sub
    You should also do some kind of error trapping to make sure that ListItem(1) exists.
    Also, what is txtEdit? A TextBox? If so, the code:

    txtEdit = Item
    txtEdit = Item.SubItems(0)

    makes little sense. I think you maybe want to do the following:

    txtEdit.Text = Item.SubItems(0)


    (But obviously you'll know more about what you are trying to do here than I).
    I hope that helps you a bit.
    Mike

  12. #12
    Join Date
    Nov 2005
    Posts
    14

    Re: edit textbox control array

    yes he is right im sorry it should be "dim LS as listitem" also make sure to multi select your listview for better selection

  13. #13
    Join Date
    Nov 2005
    Posts
    11

    Re: edit textbox control array

    thanks guys i works fine.. thank you so much

  14. #14
    Join Date
    Dec 2002
    Location
    London, UK
    Posts
    1,569

    Re: edit textbox control array

    Sure. No prob. Thats what we're here for. Glad you came right!
    Mike

  15. #15
    Join Date
    Nov 2005
    Posts
    11

    Re: edit textbox control array

    hi pinky98, got question again..
    how to update this table, i tried but every time i save it all data are change. the table has this data:

    (FieldNames)
    Name__________ Nickname_____Age
    (data)
    Nick______________little________7
    Nick______________big________17
    i would like to change the Nickname "little" to "little nick" but the data under "Nick" are change.
    can you help me with this.
    Last edited by sangkay; December 5th, 2005 at 10:04 PM.

Page 1 of 2 12 LastLast

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

Featured