Hello all,
I have a the following vba code for creating and populating a table:
and
What i need to do is to be able create the pattern above, without hard coding the dates and color patterns.
The pattern is: each color must do two consecutive morning, afternoon and nights over a 10 day cycle, which then repeats.
The vba should also be able to take a date, using this pattern, and re-create the pattern from any date in the future or past.
Not got an idea of where to start and hope you experts can assist.
Any help with this would be greatly appreciated
:banghead:
I have a the following vba code for creating and populating a table:
Code:
strCreateTableSQL = "CREATE TABLE WatchPatternDates "
strCreateTableSQL = strCreateTableSQL & "(WatchDate Date NOT NULL PRIMARY KEY, "
strCreateTableSQL = strCreateTableSQL & "Morning CHAR NOT NULL, "
strCreateTableSQL = strCreateTableSQL & "Afternoon CHAR NOT NULL, "
strCreateTableSQL = strCreateTableSQL & "Night CHAR NOT NULL);"
DoCmd.RunSQL strCreateTableSQL
and
Code:
strDateInserts = "INSERT INTO WatchPatternDates (WatchDate,Morning,Afternoon,Night)"
strDateInserts = strDateInserts & "INSERT INTO WatchPatternDates (WatchDate,Morning,Afternoon,Night)Values(01/01/2015,'Blue','Green','Amber')"
strDateInserts = strDateInserts & "INSERT INTO WatchPatternDates (WatchDate,Morning,Afternoon,Night)Values(02/01/2015,'Blue','Green','Amber')"
strDateInserts = strDateInserts & "INSERT INTO WatchPatternDates (WatchDate,Morning,Afternoon,Night)Values(03/01/2015,'Red','Blue','Green')"
strDateInserts = strDateInserts & "INSERT INTO WatchPatternDates (WatchDate,Morning,Afternoon,Night)Values(04/01/2015,'Red','Blue','Green')"
strDateInserts = strDateInserts & "INSERT INTO WatchPatternDates (WatchDate,Morning,Afternoon,Night)Values(05/01/2015,'White','Red','Blue')"
strDateInserts = strDateInserts & "INSERT INTO WatchPatternDates (WatchDate,Morning,Afternoon,Night)Values(06/01/2015,'White','Red','Blue')"
strDateInserts = strDateInserts & "INSERT INTO WatchPatternDates (WatchDate,Morning,Afternoon,Night)Values(07/01/2015,'Amber','White','Red')"
strDateInserts = strDateInserts & "INSERT INTO WatchPatternDates (WatchDate,Morning,Afternoon,Night)Values(08/01/2015,'Amber','White','Red')"
strDateInserts = strDateInserts & "INSERT INTO WatchPatternDates (WatchDate,Morning,Afternoon,Night)Values(09/01/2015,'Green','Amber','White')"
strDateInserts = strDateInserts & "INSERT INTO WatchPatternDates (WatchDate,Morning,Afternoon,Night)Values(10/01/2015,'Green','Amber','White')"
'
What i need to do is to be able create the pattern above, without hard coding the dates and color patterns.
The pattern is: each color must do two consecutive morning, afternoon and nights over a 10 day cycle, which then repeats.
The vba should also be able to take a date, using this pattern, and re-create the pattern from any date in the future or past.
Not got an idea of where to start and hope you experts can assist.
Any help with this would be greatly appreciated
:banghead: