Here is working code from a UDform
Private Sub btnEpiCustom2_Click(ByVal Sender As Object, ByVal Args As System.EventArgs) Handles btnEpiCustom2.Click
'// ** Place Event Handling Code Here **
Dim compAdapter As CompanyAdapter = New CompanyAdapter(UD102Form)
compAdapter.BOConnect()
Dim company As string = "TBT"
Dim CompAd As Boolean = compAdapter.GetByID(company)
Dim CurQuoteID As Integer = compAdapter.CompanyData.Tables("Company").Rows(0)("Number03")
Dim assignQuoteId As Integer = CurQuoteID + 1
compAdapter.CompanyData.Tables("Company").Rows(0)("Number03") = assignQuoteId
compAdapter.Update()
compAdapter.Dispose()
oTrans.GetNew()
Dim UD102 As EpiDataView = Ctype(oTrans.EpiDataViews("UD102"),EpiDataView)
UD102.dataView(UD102.Row).BeginEdit
UD102.DataView(UD102.Row)("Key1") = CurQuoteID
UD102.DataView(UD102.Row)("Date01") = Today
UD102.DataView(UD102.Row)("ShortChar02") = UD102Form.Session.UserID
UD102.dataView(UD102.Row).EndEdit
' btnEpiCustom2.Visible = False
'btnEpiCustom3.Visible = True
oTrans.update()
Private Sub btnEpiCustom2_Click(ByVal Sender As Object, ByVal Args As System.EventArgs) Handles btnEpiCustom2.Click
'// ** Place Event Handling Code Here **
Dim compAdapter As CompanyAdapter = New CompanyAdapter(UD102Form)
compAdapter.BOConnect()
Dim company As string = "TBT"
Dim CompAd As Boolean = compAdapter.GetByID(company)
Dim CurQuoteID As Integer = compAdapter.CompanyData.Tables("Company").Rows(0)("Number03")
Dim assignQuoteId As Integer = CurQuoteID + 1
compAdapter.CompanyData.Tables("Company").Rows(0)("Number03") = assignQuoteId
compAdapter.Update()
compAdapter.Dispose()
oTrans.GetNew()
Dim UD102 As EpiDataView = Ctype(oTrans.EpiDataViews("UD102"),EpiDataView)
UD102.dataView(UD102.Row).BeginEdit
UD102.DataView(UD102.Row)("Key1") = CurQuoteID
UD102.DataView(UD102.Row)("Date01") = Today
UD102.DataView(UD102.Row)("ShortChar02") = UD102Form.Session.UserID
UD102.dataView(UD102.Row).EndEdit
' btnEpiCustom2.Visible = False
'btnEpiCustom3.Visible = True
oTrans.update()
--- In vantage@yahoogroups.com, "rick_vining" <rvining@...> wrote:
>
> I am using the following code to generate a sequential serial number in the UD01 table when a button is pressed. The code works great if I use it on any field other than Key01. I can't figure out how to is get it to work with Key01 and show in a text box so they user can see the number when the button is pressed. Any suggestions would be greatly appreciated.
>
> Module Script
> '// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
> '// Begin Wizard Added Module Level Variables **
> Private WithEvents edvUD01 As EpiDataView
> '// End Wizard Added Module Level Variables **
> '// Add Custom Module Level Variables Here **
>
> Sub InitializeCustomCode()
> '// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Intialization' lines **
> '// Begin Wizard Added Variable Intialization
> edvUD01 = CType(oTrans.EpiDataViews("UD01"), EpiDataView)
> '// End Wizard Added Variable Intialization
> '// Begin Custom Method Calls
> '// End Custom Method Calls
> End Sub
>
> Sub DestroyCustomCode()
> '// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
> '// Begin Wizard Added Object Disposal
> edvUD01 = Nothing
> '// End Wizard Added Object Disposal
> '// Begin Custom Code Disposal
> '// End Custom Code Disposal
> End Sub
>
> Private Function GetNextDCO() As String
> '//Use the company Adapter to Store our sequence number Number01
> Dim nextDCO As String = String.Empty
> Dim companyAdapter As CompanyAdapter = New CompanyAdapter(UD01Form)
> companyAdapter.BOConnect()
> messagebox.show("Function GetNextDC)")
> Dim company As String = UD01Form.Session.CompanyID
> Dim found As Boolean = companyAdapter.GetByID(company)
> if (found) then
> nextDCO = companyAdapter.CompanyData.Company.Rows(0)("Number02").toString()
> companyAdapter.CompanyData.Company.Rows(0).BeginEdit()
> companyAdapter.CompanyData.Company.Rows(0)("Number02") += 1
> companyAdapter.CompanyData.Company.Rows(0).EndEdit()
> companyAdapter.Update()
> companyAdapter.Dispose()
> messagebox.show("If statement from get next ")
> end if
> return nextDCO
> End Function
>
> Private Sub edvUD01_EpiViewNotification(view As EpiDataView, args As EpiNotifyArgs) Handles edvUD01.EpiViewNotification
> '// ** Argument Properties and Uses **
> '// view.dataView(args.Row)("[FieldName]")
> '// args.Row, args.Column, args.Sender, args.NotifyType
> '// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
> If (args.NotifyType = EpiTransaction.NotifyType.AddRow) Then
> If (args.Row > -1) Then
> view.dataView(args.Row)("Key1") = GetNextDCO
> messagebox.show("Private Sub edvUD01")
>
> '// view.Notify(New EpiNotifyArgs(UD01Form, view.Row, view.Column))
> view.dataView(args.Row)("ShortChar19") = view.dataView(args.Row)("Key1")
>
> End If
> End If
> End Sub
>
> Private Sub btnEpiCustom1_MouseDown(ByVal Sender As Object, ByVal Args As System.Windows.Forms.MouseEventArgs) Handles btnEpiCustom1.MouseDown
> '// ** Place Event Handling Code Here **
> GetNextDCO()
> End Sub
>
>
>
> Rick Vining
> rvining@...
>