A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

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



 
 
Thread Tools Display Modes
  #1  
Old September 3rd, 2004, 12:44 PM
Roddy
external usenet poster
 
Posts: n/a
Default RowSourceType Property(User-Defined Function)...Help

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



  #2  
Old September 3rd, 2004, 02:00 PM
Allen Browne
external usenet poster
 
Posts: n/a
Default

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 procedu
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.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Roddy" wrote in message
...
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



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
User Defined Function dovrox General Discussion 2 June 14th, 2004 10:02 AM
AutoExpanding User Defined Function Output Arvi Laanemets Worksheet Functions 3 March 1st, 2004 11:13 AM
VBA user-defined worksheet function Val Worksheet Functions 2 December 8th, 2003 07:53 AM
Function not updating Mark Hanford Worksheet Functions 10 December 4th, 2003 02:42 PM
Error with Excel 2000 workbook ju Links and Linking 1 November 2nd, 2003 12:23 AM


All times are GMT +1. The time now is 01:33 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.