M
msmcg
I need to format the data in some textboxes using the
Binding method with custom Currency and ShortDate format
and parse handlers.
Here is the code that I am using. I call it on the form
load event:
Private Sub setTextBoxDataBindings()
'set default value for Boolean data fields
Me.objdsContractMgmt.tblContract.PortfolioPlusColumn.Defau
ltValue = False
Dim b1 As New Binding("text",
objdsContractMgmt, "tblContract.ContractEffectiveDate")
AddHandler b1.Format, AddressOf FormatShortDate
AddHandler b1.Parse, AddressOf ParseShortDate
Dim b2 As New Binding("text",
objdsContractMgmt, "tblContract.ContractExpirationDate")
AddHandler b2.Format, AddressOf FormatShortDate
AddHandler b2.Parse, AddressOf ParseShortDate
Dim b3 As New Binding("text",
objdsContractMgmt, "tblContract.LOCDate")
AddHandler b3.Format, AddressOf FormatShortDate
AddHandler b3.Parse, AddressOf ParseShortDate
Dim b4 As New Binding("text",
objdsContractMgmt, "tblContract.PriceProtectionDate")
AddHandler b4.Format, AddressOf FormatShortDate
AddHandler b4.Parse, AddressOf ParseShortDate
Dim b5 As New Binding("text",
objdsContractMgmt, "tblContract.DateAssigned")
AddHandler b5.Format, AddressOf FormatShortDate
AddHandler b5.Parse, AddressOf ParseShortDate
Dim b6 As New Binding("text",
objdsContractMgmt, "tblContract.rlnContractItems.OriginalS
pend")
AddHandler b6.Format, AddressOf FormatCurrency
AddHandler b6.Parse, AddressOf ParseCurrency
Me.editEffectiveDate.DataBindings.Add(b1)
Me.editExpirationDate.DataBindings.Add(b2)
Me.editLOCSignedDate.DataBindings.Add(b3)
Me.EditProtectedDate.DataBindings.Add(b4)
Me.editAssignedDate.DataBindings.Add(b5)
Me.editItemOriginalSpend.DataBindings.Add(b6)
End Sub
I have successfully done this for the top table in my
dataset. My dataset has 4 levels of relations. (1-M-M-M)
The code above shows the bindings that I create for each
text box or label needing special formatting. The first 5
work great. But when I introduced the 6th one, I get this
error when loading the dataset:
"Failed to enable constraints. One or more rows contain
values violating non-null, unique or foreign-key
constraints"
This field is in the child table to the top parent table.
I cannot find any examples of creating bindings like this
using relations and child tables. If I bind the text box
directly (in the UI Designer properties window) with no
special formatting, everything works fine, although the
data looks bad.
What am I doing wrong? Any help is always appreciated!
Thanks is advance...
Binding method with custom Currency and ShortDate format
and parse handlers.
Here is the code that I am using. I call it on the form
load event:
Private Sub setTextBoxDataBindings()
'set default value for Boolean data fields
Me.objdsContractMgmt.tblContract.PortfolioPlusColumn.Defau
ltValue = False
Dim b1 As New Binding("text",
objdsContractMgmt, "tblContract.ContractEffectiveDate")
AddHandler b1.Format, AddressOf FormatShortDate
AddHandler b1.Parse, AddressOf ParseShortDate
Dim b2 As New Binding("text",
objdsContractMgmt, "tblContract.ContractExpirationDate")
AddHandler b2.Format, AddressOf FormatShortDate
AddHandler b2.Parse, AddressOf ParseShortDate
Dim b3 As New Binding("text",
objdsContractMgmt, "tblContract.LOCDate")
AddHandler b3.Format, AddressOf FormatShortDate
AddHandler b3.Parse, AddressOf ParseShortDate
Dim b4 As New Binding("text",
objdsContractMgmt, "tblContract.PriceProtectionDate")
AddHandler b4.Format, AddressOf FormatShortDate
AddHandler b4.Parse, AddressOf ParseShortDate
Dim b5 As New Binding("text",
objdsContractMgmt, "tblContract.DateAssigned")
AddHandler b5.Format, AddressOf FormatShortDate
AddHandler b5.Parse, AddressOf ParseShortDate
Dim b6 As New Binding("text",
objdsContractMgmt, "tblContract.rlnContractItems.OriginalS
pend")
AddHandler b6.Format, AddressOf FormatCurrency
AddHandler b6.Parse, AddressOf ParseCurrency
Me.editEffectiveDate.DataBindings.Add(b1)
Me.editExpirationDate.DataBindings.Add(b2)
Me.editLOCSignedDate.DataBindings.Add(b3)
Me.EditProtectedDate.DataBindings.Add(b4)
Me.editAssignedDate.DataBindings.Add(b5)
Me.editItemOriginalSpend.DataBindings.Add(b6)
End Sub
I have successfully done this for the top table in my
dataset. My dataset has 4 levels of relations. (1-M-M-M)
The code above shows the bindings that I create for each
text box or label needing special formatting. The first 5
work great. But when I introduced the 6th one, I get this
error when loading the dataset:
"Failed to enable constraints. One or more rows contain
values violating non-null, unique or foreign-key
constraints"
This field is in the child table to the top parent table.
I cannot find any examples of creating bindings like this
using relations and child tables. If I bind the text box
directly (in the UI Designer properties window) with no
special formatting, everything works fine, although the
data looks bad.
What am I doing wrong? Any help is always appreciated!
Thanks is advance...