Calculate mulitple dates listbox from a single date

casey

Registered User.
Local time
Today, 14:52
Joined
Dec 5, 2000
Messages
448
Hello,

I am trying to create a listbox that shows "calculated" dates for a two week payroll. I have a field in a table that is set to a start date (05.31.05) and another field that specifies the number of days between dates (14). I would like set a listboxes recordsource to show the start date and then calculate the next 4 dates using the first date (05.31.05) and the range (14) without actually storing any dates in the table. I can figure out how to do it if the values are stored, but I just want to know if this is possible to get the results another way.This may sound crazy and unecessary, but I want to know if this is possible without storing values in the table.

Listbox values:
05.31.05 - (first date from table)
06.14.05 - (first date + 14)
06.28.05 - (first date + 2*14)
07.12.05 - (first date + 3*14)
07.18.05 - (first date + 4*14)

Is this possible? HTMS. Thanks.
 
Pat,

I get it. Use the listbox's list option and add items to the list. That makes sense. I was thinking that a query could do this, but that's alright. I think I've seen an example to do this. No article neccessary.

Thanks for your help.
 
Try this:

Code:
Function Next4Paydays(dteStart As Variant) As String
'***************************************************
're:        [url]http://www.access-programmers.co.uk[/url] _
'           /forums/showthread.php?t=88367
'Purpose:   Create a string of inputted date and
'           the next 4 dates, at 14-day intervals,
'           for use as the rowsource for a listbox.
'Coded by:  raskew
'Inputs:    from the debug (immediate) window
'           (1) ? next4paydays("5/31/05") --or--
'           (2) ? Next4Paydays(#5/31/05#)
'Output:    5/31/05; 6/14/05; 6/28/05; 7/12/05; 7/26/05
'***************************************************

Dim dteHold As Date
Dim strHold As String
Dim n       As Integer

    dteHold = DateValue(dteStart)
    
    For n = 1 To 5
       strHold = IIf(Len(strHold) > 0, strHold & "; ", "")
       strHold = strHold & Format(dteHold)
       dteHold = DateAdd("d", 14, dteHold)
    Next n
    
    Next4Paydays = strHold

End Function
HTH - Bob
 

Users who are viewing this thread

Back
Top Bottom