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!

Adding dates to a combo/list box

Status
Not open for further replies.

moben

IS-IT--Management
Feb 5, 2002
116
0
0
GB
Dear All,

I have a Access 2000 database application.

I want to add dates to combo/list box (which ever is easier).

The values will be the current day, current day +1, and current day +2.

If the current date falls on a Friday, then Current day+1 should Monday etc.

The user can select one of the 3 dates from this box.

Does anybody have any idea how this can be done ?

Feedback/advice/solution really appreciated.

Moen.

 
In a query you could use this sql

SELECT Date() AS Fld1, IIf(Weekday(Date())+1=7,Date()+3,Date()+1) AS Fld2, IIf(Weekday([Fld2])=6,[Fld2]+3,[Fld2]+1) AS Fld3;

This should do it, but you will want to test the iif's a bit further.

Paul
 
I woulde do it this way create a table <digits> with 1 <Digitid> field a number
Add at least 5 records to it 1-5
Set the recordsource of the combobox to
[
code JetSql]
SELECT TOP 3 DateAdd("d",[DigitID],Date()) AS Expr1
FROM Digits
WHERE (((Weekday(DateAdd("d",[DigitID],Date()))) Between 2 And 6));

[/code]
 
Thank you very much for the quick responses.

I have managed to get a query to create the dates, but if I link the combo to the query.... only 1 row is returned (unless I increase the value of the column count of the combo box) i.e. can only scroll horizontally.

I need the query to return the dates as individual records, which would be displayed within the combo, probably similar to Pwise has said ?

regards,

Moben
 
if you will tell me what is wrong with my query I can help you
 
Verticalisation of PaulBricker's query:
SELECT Date() AS Fld1
UNION SELECT IIf(Weekday(Date())=6,Date()+3,Date()+1)
UNION SELECT IIf(Weekday(Date())>=5,Date()+4,Date()+2)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks for your help, I have not yet tried your solutions, aim to do so this weekend, will get back to you.

Regards,

Moben.
 
Thanks for your help.

I used Pwise's code (modified it slightly to include current day i.e. [DigitID]-1 )and it works.

Thanks,

Mob.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top