View Full Version : Combo-boxes/Dates


LJ
11-12-2001, 03:27 AM
Please help, as I am having a lot of trouble with my combo-boxes. Hope you understand this.

If I have a Timescale combo box with three options referring to dates:
Same date, Within 5 days, Other.

If I select Within 5 days from one combo box, and select the 6th as my target date from another; my completion date jumps to the 10th as expected. However, I want to make this optional only. For instance, I would like to have the opportunity to change the 10th to any other date, as well as having it default to 4 more than the target, but this won’t happen. I can’t choose anything. How do I rectify this problem?

I have used this formula for my Control source for my Completion date:

=IIf([Timescale]="Within 5 Days",[Tardate].ListIndex+5,[Tardate])

and =[Tardate] for my default Completion date value

I am using =DatePart("d",[Day]) to extract the day. This returns 1, 2, 3 etc, and not 1st , 2nd, 3rd. Do you know how I rectify this?

The month returns 11 for NOV also. How do I change this, so that it returns NOV etc.

When I choose Other from the Timescale combo box, target=completion (same effect as choosing Same date). I want to be able to choose any date under the completion date. How do I do this? ( I don’t know how to add this into my IIf statement above).

Also when I choose the target date as the 28th, the completion date goes to 32.
How do I rectify this?

Fizzio
11-13-2001, 04:53 AM
Why not instead of using a combo box to pick the date, use a calendar. Then use your combo box to select a timescale. Use a textbox to show the completion date and instead of setting the control source as you have, keep it unbound then set the value by code using an if then statement eg (Syntax may not be accurate). You can still set the default value to Me.Calendar.Value +4 (Calendar is the name of the calendar)

Private Sub ComboBox_AfterUpdate()
if comSelectTarget = 1 Then
txtCompletionDate = Me.Calendar.Value
elseif: comSelectTarget = 2 Then txtCompletionDate = Me.Calendar.Value +4
elseif: comSelectTarget = 3 Then txtCompletionDate.SetFocus ' or open an inputbox to input a date
End If