Combobox list a year of Saturday dates

sierra467

Registered User.
Local time
Today, 13:01
Joined
Aug 1, 2005
Messages
66
I have a form and I need a combobox on the form to produce a list of Dates for every Saturday starting from the current day displayed in a short format for the user to select. Does anyone have an idea how I could manage that?

I was going to make a table and write in each one and use that for the rowsource, but someone said that there might be a way to do that dynamically.
 
I dont know how to do it but I know it'll involve 'vbSaturday' if that is any help
 
look at call back function to fill a combo box
 
OK thanks, I am not sure what you mean about the vbSaturday and call back function. Is that some sort of a vba command. I will try to look that up and see if it will help.
 
in Access 97. you can find the help for this under

combo bxxes, creating , then
create a list box or combo box that gets its rows from a function

the code example actually generates a list of Mondays!

or try searching for rowsourcetype in help to get you to the right bit.
Hope this helps
 
Solution

I had a friend send me some code to locate a Monday and I modified it to find a Saturday. I would love to say that I totally understood it, but I am not sure that I do. It just seems to work. The key seemed to be the 14 in the intOffset statement but I am not so sure what the significance of that is. I tried multiple numbers shown in the comment to see what they did, but as you see some did the same thing. Hope this helps others too.

Code:
Function ListSaturdays(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.
            ListSaturdays = True
            
        Case acLBOpen                   'Open.
            ListSaturdays = Timer      'Unique ID.
            
        Case acLBGetRowCount        'Get rows.
            ListSaturdays = 4            'Number of Saturdays to display
            
        Case acLBGetColumnCount    'Get columns.
            ListSaturdays = 1
            
        Case acLBGetColumnWidth    'Get column width.
            ListSaturdays = -1           'Use default width.
            
        Case acLBGetValue              ' Get the data.
            'The following: Sunday is 4 or 8 or 15; Monday is 3 or 9; Tuesday is 2 or 10; Wednesday is 1 or 11; Thursday is 0 or 12;  Friday is 6/13; Saturday is 5 or 7 or 14
            intOffset = Abs((14 - Weekday(Now)) Mod 7)
            ListSaturdays = Format(Now() + intOffset + 7 * row, "mm/dd/yyyy")
            
     End Select
     
End Function
 
yes, thats the call back function, I mentioned. Its hard to follow isnt it.
 

Users who are viewing this thread

Back
Top Bottom