RowSourceType Property(User-Defined Function)...Help

R

Roddy

Hi,
Can anyone provide information or links to data about the
first two arguments (fld and id) of the rowSourceType User-
Defined Function. The fld argument is always Null and never
refers to the list box being filled. Also the id argument
is always -1. Below is copy of my program and a copy of
the output. Thanks in advance.
Roddy

Option Compare Database
Option Explicit
'*****************************************
' ListBox Properties
' Name lbxTest
' Rowsource type lbxHandler
' Column Count 5
' Column Heads no
' Column Withs 0.4";0.4";0.6";0.8"
' Withs 4.1667"
'*****************************************

Private Function UdtHandler(fld As Control, id As Variant,
_
row As Variant, col As Variant, _
Code As Variant) As Variant

Static PrintHeader As Boolean
Dim varRetVal As Variant

varRetVal = -1
Select Case Code
Case 0
varRetVal = True
Case 1
varRetVal = Timer
Case 3
varRetVal = 1
Case 4
varRetVal = 5
Case 5
varRetVal = -1
Case 6
varRetVal = "R"
Case 7
varRetVal = -1
Case 8
Case 9
End Select

'Stop
On Error GoTo Err_Handler
Exit_Handler:
'Print values
If Not PrintHeader Then
Debug.Print "Code", " id", " row", " col", "
fld", "fld TypeName", "VarRetVal"
PrintHeader = True
End If
Debug.Print Code, id, row, col, fld, TypeName(fld),
varRetVal

UdtHandler = varRetVal
Exit Function
Err_Handler:

Debug.Print "** ERR ** "; Err.Number; ", in source ";
Err.Source; ", Desc= "; Err.Description
Resume Exit_Handler
End Function

Private Sub Form_Open(Cancel As Integer)
Debug.Print "** Form_Open Event **"
End Sub

Private Sub Form_Close()
Debug.Print "** Form_Close Event **"
End Sub

'***************************************** OUTPUT
*****************************************

'Code id row col
fld fld TypeName VarRetVal
' 0 -1 -1 -1
Null ListBox True
' 2 -1 -1 -1
Null ListBox -1
' 4 -1 -1 -1
Null ListBox 5
' 5 -1 -1 0
Null ListBox -1
' 5 -1 -1 1
Null ListBox -1
' 5 -1 -1 2
Null ListBox -1
' 5 -1 -1 3
Null ListBox -1
' 5 -1 -1 4
Null ListBox -1
' 5 -1 -1 0
Null ListBox -1
' 3 -1 -1 -1
Null ListBox 1
' 5 -1 -1 1
Null ListBox -1
' 5 -1 -1 2
Null ListBox -1
' 5 -1 -1 3
Null ListBox -1
' 6 -1 0 0
Null ListBox R
' 7 -1 -1 0
Null ListBox -1
' 6 -1 0 1
Null ListBox R
' 7 -1 -1 1
Null ListBox -1
' 6 -1 0 2
Null ListBox R
' 7 -1 -1 2
Null ListBox -1
' 6 -1 0 3
Null ListBox R
' 7 -1 -1 3
Null ListBox -1
' 6 -1 0 4
Null ListBox R
' 7 -1 -1 4
Null ListBox -1
'** Form_Open Event **
'** Form_Close Event **
' 8 -1 -1 -1
Null ListBox -1
' 9 -1 -1 -1
Null ListBox -1
 
A

Allen Browne

Hi Roddy.

You can generally ignore the first 2 arguments of the callback function, but
here is what they do.

The fld argument is a reference to the list box (or combo box) being filled
by the function. You should be able to view the name of the control when it
is being loaded by adding this line to the procedure:
Debug.Print fld.Name

The ID argument is the unique identifier for the control. You are generally
not interested in this,but it may be useful if you are filling multiple
controls by the same function. In my test, it appeared to contain either -1
(typical value used for "irrelevant") and the integer that that was assigned
by the Timer when the Code argument was acLBOpen.

BTW, you better believe the documentation when it says that there is no way
to know the order that Access will ask for things. IME, you need to load a
static array in acLBInitialize to get acceptable performance, rather than
open a recordset and look up the value each time. (Of course you do not need
to do that if you are just calculating values on the fly, as in the
ListMondays() example.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top