I do this in a rather 'clunky' way and it takes extra effort but it works.
The following example shows a toolbox routine to get the id field from any table by providing 'a' name.
All my tables have an id field and the names are unique.
The AE ( Application Error management) module has a collection that is used like a stack.
Procedure calls are loaded as they are accessed and removed as the procedure closes.
statement removes the next procedure listed in the stack and as all procedures close,
the stack empties.
The AE module generates an error form from scratch and then provides valuable data to error tracking.
I've found over the years that the extra effort in coding is worth the benefits of being able to quickly identify the error
and to be able to see the values of the parameters passed.
It also lists the backtrace in reverse order
so that it's easier to follow.
Note # The return statement HAS to be after the stack remove call as once you call a RETURN statement in
any procedure, it terminates and no other statements are processed
Public Function GetIdFromName(InTable As String, InField As String, InName As String) As Integer
Dim $Rec As Result
Dim $Query As String = "SELECT Id," & InField & " FROM " & InTable & " WHERE " & InField & " = '" & InName & "'"
Dim TmpId as Integer = 0
AE.ErrorWhere = "Public Function GetIdFromName(InTable As String, InField As String, InName As String) As Integer" & Gb.NewLine
AE.ErrorWhere &= "Par1: " & InTable & Gb.NewLine
AE.ErrorWhere &= "Par2: " & InField & Gb.NewLine
AE.ErrorWhere &= "Par3: " & InName
$Rec = DB.$Con.Exec($Query)
If (Not IsNull($Rec)) And $Rec.Available Then TmpId = $Rec!Id
AE.DisplayErrorData(2, Error.Text, Error.Class, Error.Where, Error.Code, Error.Backtrace)
This is an example of the output of a typical error.
Cheers - Quin.
I code therefore I am