I have sstab with 9 tabs. Each tab have 4 text box. I have named all the textboxes in arrays. For eg. In first tab the array is txtbox0(0),txtbox0(1),txtbox0(2),txtbox0(3)... Similarly in the second tab, ihave six text boxes named as txtbox1(0),txtbox1(1),txtbox1(2),txtbox1(3)..... Each of this tab shows one table of my datbase and textboxes as fields in each table.

I want to create procedure for add/ modify adodc recordsets for the textboxes. How do i access the textboxes ?

Recommended Answers

All 4 Replies

You dont want to be using text box's for this, looks like your
going through a whole lot of trouble for nothing.

you should be using a muticolumn listbox i think.

much easier to work with for both populating and reading so you can do whatever
you want with the data from there in stead of reading each text box you have above.

here is an example to populate and read a listbox

ListView3.Columns.Add("NAME", 150, HorizontalAlignment.Left)
        ListView3.Columns.Add("SCREEN NAME", 150, HorizontalAlignment.Left)
        ListView3.Columns.Add("LOCATION", 150, HorizontalAlignment.Left)
        ListView3.Columns.Add("URL", 100, HorizontalAlignment.Left)
        ListView3.Columns.Add("c1", 100, HorizontalAlignment.Left)
        ListView3.Columns.Add("c2", 100, HorizontalAlignment.Left)
        ListView3.Columns.Add("System", 60, HorizontalAlignment.Left)
        



  Dim ScreenName As System.Xml.XmlNodeList = doc.GetElementsByTagName("screen_name")
            Dim location As System.Xml.XmlNodeList = doc.GetElementsByTagName("location")
            Dim Str2 As String = ""
            Dim Str3 As String = ""

' this part was to read an xml document that had these nodes,, 
            For Each node In doc.DocumentElement.SelectNodes("//user")
               
                Dim str(7) As String
                Dim itm As ListViewItem



                str(0) = node.Item("name").InnerText
                str(1) = node.Item("screen_name").InnerText
                str(2) = node.Item("location").InnerText
                str(3) = node.Item("url").InnerText
                str(4) = node.Item("count1").InnerText
                str(5) = node.Item("count2").InnerText
                 str(6) = node.Item("System").InnerText
                
               
                itm = New ListViewItem(str)
            ListView3.Items.Add(itm)
next
               




' THIS WILL READ THE LISTBOX
For Each item As ListViewItem In ListView3.Items

                For Each subItem As ListViewItem.ListViewSubItem In item.SubItems

                    currentLine &= (String.Format("""{0}"",", subItem.Text))

                Next
                

                ' do what ever you want with the data here

            Next

It will be time and pc resources consuming to load every tab with data if the user only wants to view a certain tab, so, first determine which tab is open by using the following code and then populate said tab with data -

If ssTab.Tab = 0 Then
   txtBox0(0).Text = rsMyDataSet!TheFirstFieldInMyTable
   txtBox0(1).Text = rsMyDataSet!TheSecondFieldInMyTable
   'And so on...
End If

Thanks for the reply,
Population of the records is not problem. I have been able to populate my records very well. But the problem arrives while updating of records. I am trying to create small procedure with variable as recordset, index of the sstab and the number of text boxes in that particular tab. Their is master tab of 9 tabs and each tab consists of different number of textboxes with same name but in array. How do I get the textbox names and their text in the textbox for saving or modifying. Hope you get get me.

Still a little bit of confusion here...

Who would add text to the textboxes? The user?
Is your fields in the respective tables in the database set to the textboxes? In other words, textbox0(1) is only for receiving a phone number, textbox0(2) is only for receiving an address etc. These only allowed text can now be added to a table with fields "PhoneNumber" and "Address". What is your ssTab used for?

You can start a function in a module by using the following, but please reply on the above questions and I am sure that I can help you design the complete function...

Public Function SaveMyData(rsTab As RecordSet, MyssTab As ssTab, txtIndex As TextBox
'All declerations need to go here, as in Set rsTab = New ADODB.RecordSet etc
End SUb
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.