Select Option on Combo Box update return date?

GregSmith

Registered User.
Local time
Today, 14:53
Joined
Feb 22, 2002
Messages
126
I have a table with a field name called reture date and the default value is:
=DateAdd("d",21,Date())

In my form when you select Daily from the Combo box, I want return date to equal current date + 21 ( I have this part working)

If you select monthly, I want the return date to add 1 month and if you select yearly, I want the year to go up 1...

Any ideas??

This is what I have so far for the code:

Private Sub Combo67_Change()
If [Session 1 Name] = 1 Then
Me.[Return Date] = DateAdd("d", 21, Date)
End If

If [Session 1 Name] = 2 Then
Me.[Return Date] = DateAdd("d", 365, Date)
End If

If [Session 1 Name] = 3 Then
Me.[Return Date] = DateAdd("d", 2555, Date)
End If

End Sub
 
Where does [Session 1 Name] come from? Anyway, try this:
Code:
Private Sub Combo67_AfterUpdate()
 Select Case Me.Combo67.Value
  Case "Daily"
    Me.[Return Date] = DateAdd("d", 21, Date())
  Case "Monthly"
    Me.[Return Date] = DateAdd("m", 1, Date())
  Case "Yearly"
    Me.[Return Date] = DateAdd("y", 1, Date())
  Case Else
    Me.[Return Date] = Null 'blank combo
 End Select
End Sub

This of course assumes your combo is textual. Change as needed.

HTH,
David R
 
Session 1 Name is my combo box that lists my entries: daily monthly yearly and it's from a table called backup specs

BTW: I tried your code and it does not update correcly...

The "d" works great but the "m" or "y" does not work correctly...


[This message has been edited by GregSmith (edited 04-12-2002).]
 
If [Session 1 Name] is the combobox's name then code for Combo67 will not work worth a flying fig on it. Check the Properties>Other>Name value to make sure we are talking about the same field.

Please define 'does not work correctly' a little more clearly. I was working from memory so I forgot that yearly would be "yyyy". not "y". Consult the Access help. But the "d" and "m" fields give the right result, as does the "yyyy" on my computer: Access 2000, Windows 2000.

Please post back with more information.

David R

[This message has been edited by David R (edited 04-15-2002).]
 

Users who are viewing this thread

Back
Top Bottom