How to reference text on windows form while in public function
Posted on 2006-05-12
Below is a function I use in multiple forms to define my main table's dataset.
Public Function GetMainTable() As DataSet
Dim da As New SqlDataAdapter
da = GetMainTableDA(True)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OKOnly Or MsgBoxStyle.Critical, Me.Text)
Also, from inside the activated form:
dtMainTable = GetMainTable().Tables("invoice_header")
The first piece of code was previously contained in each form....very redundant and I wanted to clean it up.
I pasted it into my Module1.vb. Needless to say it does not like the 'Me' reference when attempting to capture an error.
How would I add to/modify the code from within the original form and the code from my public function to get the appropriate form name in order to resolve my problem? I pray that it is as simple as it was in MS Access.....xText = Forms![formname].txtfieldname for example.
Thanks for any assistance you can give.