Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping through

Status
Not open for further replies.

mxo

Programmer
May 20, 2005
51
ZA
Hi All

I just cannot get this right basicly what Im trying to achieve: is I got dataset called "customer" (dataset_name) and it has a "NewCustomers" (table_name) and on this table i want my textbox: txtShipTo.text to be the same with txtCustAddress.text if the condition is true and it must do the same to all the fields that suit the condition.



Dim tbl as DataTable
Dim Clm as DataColumn

Tbl = Customer.Tables(“NewCustomer”)

For each clm In tbl.Columns
If txtCustName.text = txtCustTradingAs.text Then
txtShipTo.text = txtCustAddress.text
End if
Next

 
Is this a datatable?

If so, use the Table.Select statement.

I hope this helps.


Ron Repp

If gray hair is a sign of wisdom, then I'm a genius.
 
Im not sure do you mean something like this because i have tried with no luck,also not if i did a right thing.

Dim dr() As DataRow
Dim tbl As DataTable
tbl = DataSet1.Tables("NewCustomers")

For each myRows = myTable.Select()
If txtCustName.text = txtCustTradingAs.text Then
txtShipTo.text = txtCustAddress.text
End if
Next
 
For instance:

DataTable: NewCustomers
Fields (ColumnsName): "CustName", "ShipTo"

Code:
Dim dr As DataRow()
'Filter only records where "CustName" field equals txtCustName.Text
dr = DataSet1.Tables("NewCustomers").Select("CustName='" & txtCustName.Text & "'")
'Loop through dr
For each myRows as DataRow in dr
    'Set the value
    dr("ShipTo") = txtCustAddress.text 
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top