Hi Eric,
Here's the gist of this type of customization:
1. Add two label controls at the bottom of the form for each description
2. The account description is loaded from the db in the cacct_Chk event
3. The subaccount description is loaded from the db in the csub_Chk event
4. Both descriptions are refreshed in the Spread1_LineGotFocus event
When you load the account and subaccount decriptions from the database, set the label captions using the SetProps call with PROP_CAPTION.
Here's sample code to retrieve the subaccount description. It is developer preference as to whether the cursor is globally scoped or not. I find that local scope is easier to maintain and the performance impact is negligible. You'll want to check around this code block to ensure that the subaccount number is not blank, and if it is, set the description to blank. To get the current value of the subaccount, use this call: GetObjectValue("cSub").
Also note that in SL7 VBA, LenB(<buffer>) must still be passed to the SqlFetch API call, even though it is has been removed in the corresponding SDK (VBTools) API call.
---------------------------
Dim SqlStr As String
Dim csr_SubAcct As Integer
Call SqlCursorEx(csr_SubAcct, NOLEVEL + SqlFastReadOnly, "csr_SubAcct", "", "")
SqlStr = "SELECT * from Subacct (NOLOCK) WHERE Sub=" & SParm(SubAccount)
serr1 = SqlFetch1(csr_SubAcct, SqlStr, bSubAcct, LenB(bSubAcct))
Call SqlFree(csr_SubAcct)
'-- Update label caption
If serr1 = 0 Then
Call setprop(LabelControlName, PROP_CAPTION, DefaultLabelCaption & Trim$(bSubAcct.Descr))
Else
Call setprop(LabelControlName, PROP_CAPTION, DefaultLabelCaption)
End If
'-- Refresh UI
Call DispFields(FormName, LabelControlName)
---------------------------
Paul