DavidT_macktool
Well-known member
I pass 3 variables to the form: icurrentShopNumber, icurrentPartID, and AddShopNumber. AddShopNumber number is boolean.
I load up the form with the current info needed from the Part and ShopNumber datasets and then check to see if we are adding a shopnumber record. If we are, a new datarow is added.
This all works.
I need the code to refresh the textbox displaying the ShopNumberID which is an autoincrement/identity field in the sql dataset. The record is added correctly, i can save it and go back to the grid form of the ShopNumber dataset and the record is correctly sequenced at the end.
How can i (refresh) the textbox.text to display the added ShopNumber when the form is opened?
the bindings for the textbox:
'editShop_Number
'
Me.editShop_Number.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.DsShopNumber21, "Shop Number.Shop Number"))
Me.editShop_Number.Location = New System.Drawing.Point(232, 16)
Me.editShop_Number.Name = "editShop_Number"
Me.editShop_Number.TabIndex = 32
Me.editShop_Number.Text = ""
'
the code for the form load:
PrivateSub frmShopNumber2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
SqlSelectCommand1.Parameters("@shopnum").Value = iCurrentShopNum
SqlSelectCommand2.Parameters("@partid").Value = iCurrentPartid
Me.LoadDataSet()
lblShopNum.Text = iCurrentShopNum.ToString
If addShopNumber = TrueThen
Try
Me.BindingContext(DsShopNumber21, "Shop Number").EndCurrentEdit()
Dim tblShopNum As DataTable
tblShopNum = DsShopNumber21.Tables("Shop Number")
Dim drCurrentSN As DataRowdrCurrentSN = tblShopNum.NewRow()Dim dt As DateTime = DateTime.NowdrCurrentSN("Part ID") = iCurrentPartid
drCurrentSN("date added") = dt.ToShortDateString
drCurrentSN("traveler") = editTraveler.CheckState = CheckState.Unchecked
drCurrentSN("open") = editOpen.CheckState = CheckState.Checked
drCurrentSN("shop class") = "shop"
tblShopNum.Rows.Add(drCurrentSN)
Catch eEndEdit As System.Exception
System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
EndTry
EndIf
EndSub
Thanks,
David
I load up the form with the current info needed from the Part and ShopNumber datasets and then check to see if we are adding a shopnumber record. If we are, a new datarow is added.
This all works.
I need the code to refresh the textbox displaying the ShopNumberID which is an autoincrement/identity field in the sql dataset. The record is added correctly, i can save it and go back to the grid form of the ShopNumber dataset and the record is correctly sequenced at the end.
How can i (refresh) the textbox.text to display the added ShopNumber when the form is opened?
the bindings for the textbox:
'editShop_Number
'
Me.editShop_Number.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.DsShopNumber21, "Shop Number.Shop Number"))
Me.editShop_Number.Location = New System.Drawing.Point(232, 16)
Me.editShop_Number.Name = "editShop_Number"
Me.editShop_Number.TabIndex = 32
Me.editShop_Number.Text = ""
'
the code for the form load:
PrivateSub frmShopNumber2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
SqlSelectCommand1.Parameters("@shopnum").Value = iCurrentShopNum
SqlSelectCommand2.Parameters("@partid").Value = iCurrentPartid
Me.LoadDataSet()
lblShopNum.Text = iCurrentShopNum.ToString
If addShopNumber = TrueThen
Try
Me.BindingContext(DsShopNumber21, "Shop Number").EndCurrentEdit()
Dim tblShopNum As DataTable
tblShopNum = DsShopNumber21.Tables("Shop Number")
Dim drCurrentSN As DataRowdrCurrentSN = tblShopNum.NewRow()Dim dt As DateTime = DateTime.NowdrCurrentSN("Part ID") = iCurrentPartid
drCurrentSN("date added") = dt.ToShortDateString
drCurrentSN("traveler") = editTraveler.CheckState = CheckState.Unchecked
drCurrentSN("open") = editOpen.CheckState = CheckState.Checked
drCurrentSN("shop class") = "shop"
tblShopNum.Rows.Add(drCurrentSN)
Catch eEndEdit As System.Exception
System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
EndTry
EndIf
EndSub
Thanks,
David