Answer to placing values in a field in Tab A from Tab B

W

Woody Splawn

Last week there was a rather long exchange on this newsgroup titled Why this
no work" I will delineate the solution below. It is simple. I don't know
why someone else didn't suggest it. Oh well <g>. Instead of trying to
update the field in the usual way you have to update the datatable instead.

To restate the problem. I had a Winform with a tab on it. I had code in a
button on tabA that updated a field in tab A. I could put similar code in a
button on TabB (to update the the field in Tab A) but it would not work.
Same code, the only difference was that the code was being called from a
different tab. The code did work if the fields were not bound but in my
case the fields are bound. The solution to how to make the field in TabA
get updated with the proper value is to not try to do it with code like
this:

'Me.txtBalDue.Value = 4

But rather with code like this:

Dim Dt As DataTable
Dt = DsMain1.Tables("Contracts")
Dt.Rows(0)("BalDue") = 4
 
F

Fergus Cooney

Hi Woody,

I suggested that

|| You say you set the TextBox value. Some last questions
||
|| Are you expecting the DataSource to update? Is it doing so?
|| If not, can you set the DataSource directly? If you do, does
|| your TextBox now display the correct value?

And so did Peter Huang.

|| I think you can work around the problem by change the value
|| of the dataset directly.
|| Private Sub Button1_Click(...) Handles Button1.Click
|| 'TextBox1.Text = "ee"
|| DataSet11.Tables(0).Rows(0)(0) = "ee"
|| End Sub

;-)

Regards,
Fergus
 
W

Woody Splawn

Fergus

Thank you for your help and interest. I am unable to find your suggestion
though I don't doubt you made it.

I did find Peter's suggestion. It was posted yesterday (Sunday) and I did
not see it today untill you brought it to my attention.

I do try to read the responses carefully. Thank you again to you and all
who try to assist.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top