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
Printable View
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
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
here is my program..
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
ok. how do i code it when i want to save it again?
CNN.Execute "INSERT into inquiry" & _
" (CLIENTID, LOANACCOUNTNUMBER, CLIENTNAME)" & _
" VALUES ('" & txtClientID & "'," & _
" '" & txtLoanAccount & "'," & _
" '" & txtname & "')"
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 :)
hi! olocin, i got index out of bounds error
post the code, to where the error occurs
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
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:
You should also do some kind of error trapping to make sure that ListItem(1) exists.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
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.
yes he is right im sorry it should be "dim LS as listitem" also make sure to multi select your listview for better selection :)
thanks guys i works fine.. thank you so much
Sure. No prob. Thats what we're here for. Glad you came right!
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.