Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Combo Box

Status
Not open for further replies.

5556

Programmer
May 27, 2003
17
0
0
US
I need to make a combo box on a form that has a weeks worth of dates that stays current every time the form is opened. I am not sure how to do this.
 
Hi

Assuming you have combo box declared to accept its data as a list (ie RowSourceType = Value List) then something like:

Dim i as Integer
Dim strList as String
strList = ""
For i = 7 to 1 Step -1
If Len(strList) = 0 Then
strList = DateAdd("d",-i,Date())
Else
strList = ";" & strList
strList = strList & DateAdd("d",-i,Date())
End If
Next i
cboDate.RowSource = strList

should do it, you may need to add a format statement around the date, I have not done this becuase I do not know where you are and if you are using Uk style date or US style date



Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top