For Douglas Steele

G

Giangi

Doug wrote in this section (at 3/3/2006):
"If you're determined, though, you can write a function that can be used as
the RowSourceType for the listbox.

http://msdn.microsoft.com/library/en-us/vbaac11/html/acproRowSourceTypeFunctionParameters
gives the details for this function (don't worry if you're not using Access
2003: that function works in all versions of Access)"

I am interesting to this argument, but address is wrong !
Would you write right address for help me ?
Many thanks in advance
 
D

Douglas J. Steele

The "Case acLBGetColumnCount" section needs to return the correct number of
columns, and the "Case acLBGetValue" section needs to look at the value that
was passed to the function as col to know which value to return. (col will
start at 0, not 1)

If you wanted the first example to return a number as well as the date, you
could use something like:

Function ListMondays(fld As Control, id As Variant, _
row As Variant, col As Variant, code As Variant) _
As Variant
Dim intOffset As Integer
Select Case code
Case acLBInitialize ' Initialize.
ListMondays = True
Case acLBOpen ' Open.
ListMondays = Timer ' Unique ID.
Case acLBGetRowCount ' Get rows.
ListMondays = 4
Case acLBGetColumnCount ' Get columns.
ListMondays = 2
Case acLBGetColumnWidth ' Get column width.
ListMondays = -1 ' Use default width.
Case acLBGetValue ' Get the data.
Select Case col
Case 0
ListMondays = row
Case 1
intOffset = Abs((9 - WeekDay(Now)) Mod 7)
ListMondays = Format(Now() + _
intOffset + 7 * row, "mmmm d")
End Select
End Select
End Function

If you wanted something other than default column widths, you could use:

Case acLBGetColumnWidth
Select Case col
Case 0
ListMondays = 720
Case 1
ListMondays = -1
End Select

(widths are specified in twips, so the first column would be set to
half-an-inch wide.)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Giangi said:
Many thanks, mr. Doug, this is right.

I would modify this code for multi column listbox: woul you help me?
Thanks.
 
G

Giangi

Thanks again, Doug.
Now I am "chin deep in the hoopla", but next thursday I will try your suggest.
Good night and good luck.
 
Top