hello all
i have just a simple question about the little thing i have been playing around with lately. I wanna try to make a schedule for this place i am working at, and i have all the preferred times of the workers in a DB table, and i have the following code and please if ya can, please point out some obvious mistakes that i am making. this thing is been pushin me up the wall for a week now, and this is the best i could come up with (a lil sad i know)
Option Explicit
Private Sub form_Activate()
'counters for loops
Dim i As Integer
Dim n As Integer
'arrays that are used for loops and to hold
'the schedule
Dim days(1 To 7) As String
Dim Time4Work(1 To 31) As Double
Dim work(1 To 7, 1 To 31) As String
'database related declaration
datSchedule.Visible = False
datSchedule.DatabaseName = "C:\db1.mdb"
Dim SQLStr As String
days(1) = "Monday"
days(2) = "Tuesday"
days(3) = "Wednesday"
days(4) = "Thursday"
days(5) = "Friday"
days(6) = "Saturday"
days(7) = "Sunday"
Time4Work(1) = 8 '8am
Time4Work(2) = 8.5 '8:30am
Time4Work(3) = 9
Time4Work(4) = 9.5
Time4Work(5) = 10
Time4Work(6) = 10.5
Time4Work(7) = 11
Time4Work(8) = 11.5 '...
Time4Work(9) = 12
Time4Work(10) = 12.5
Time4Work(11) = 13
Time4Work(12) = 13.5
Time4Work(13) = 14
Time4Work(14) = 14.5
Time4Work(15) = 15
Time4Work(16) = 15.5 '3:30pm
Time4Work(17) = 16
Time4Work(18) = 16.5
Time4Work(19) = 17
Time4Work(20) = 17.5
Time4Work(21) = 18
Time4Work(22) = 18.5
Time4Work(23) = 19
Time4Work(24) = 19.5
Time4Work(25) = 20 '...
Time4Work(26) = 20.5
Time4Work(27) = 21
Time4Work(28) = 21.5
Time4Work(29) = 22
Time4Work(30) = 22.5
Time4Work(31) = 23 '11pm
'SQL Statement to fill in the 2D array
'the first index is the number that corresponds to the
'day, second is the
'number that corresponds to the Time4Work. ie, the
'student available to work
'on Tuesday between 8 and 8:30 will be at the position
'work(2,1)
'For i = 1 To 7
' For n = 1 To 31
' if n=31 then
' sqlstr = SELECT [First Name] FROM [times] WHERE [Day] = days(i) AND ( [Start Time] <= 22.5 'handles the 22.5 till 23 shift
' datSchedule.RecordSource = sqlstr
' work(i, n) = datschedule.recordsource
' else
' sqlstr = SELECT [First Name] FROM [times] WHERE [Day] = days(i) AND ( [Start Time] <= Time4Work AND [End Time] >= Time4Work(n+1)
' datSchedule.RecordSource = sqlstr
' work(i, n) = datschedule.recordsource
' end if
' Next n
' Next i
End Sub
sorry for messiness, and as always i appreciate any help and suggestions you guys provide me with.
thanks
vlada .:have i mentioned that i am still a newbie to this game? :.
i have just a simple question about the little thing i have been playing around with lately. I wanna try to make a schedule for this place i am working at, and i have all the preferred times of the workers in a DB table, and i have the following code and please if ya can, please point out some obvious mistakes that i am making. this thing is been pushin me up the wall for a week now, and this is the best i could come up with (a lil sad i know)
Option Explicit
Private Sub form_Activate()
'counters for loops
Dim i As Integer
Dim n As Integer
'arrays that are used for loops and to hold
'the schedule
Dim days(1 To 7) As String
Dim Time4Work(1 To 31) As Double
Dim work(1 To 7, 1 To 31) As String
'database related declaration
datSchedule.Visible = False
datSchedule.DatabaseName = "C:\db1.mdb"
Dim SQLStr As String
days(1) = "Monday"
days(2) = "Tuesday"
days(3) = "Wednesday"
days(4) = "Thursday"
days(5) = "Friday"
days(6) = "Saturday"
days(7) = "Sunday"
Time4Work(1) = 8 '8am
Time4Work(2) = 8.5 '8:30am
Time4Work(3) = 9
Time4Work(4) = 9.5
Time4Work(5) = 10
Time4Work(6) = 10.5
Time4Work(7) = 11
Time4Work(8) = 11.5 '...
Time4Work(9) = 12
Time4Work(10) = 12.5
Time4Work(11) = 13
Time4Work(12) = 13.5
Time4Work(13) = 14
Time4Work(14) = 14.5
Time4Work(15) = 15
Time4Work(16) = 15.5 '3:30pm
Time4Work(17) = 16
Time4Work(18) = 16.5
Time4Work(19) = 17
Time4Work(20) = 17.5
Time4Work(21) = 18
Time4Work(22) = 18.5
Time4Work(23) = 19
Time4Work(24) = 19.5
Time4Work(25) = 20 '...
Time4Work(26) = 20.5
Time4Work(27) = 21
Time4Work(28) = 21.5
Time4Work(29) = 22
Time4Work(30) = 22.5
Time4Work(31) = 23 '11pm
'SQL Statement to fill in the 2D array
'the first index is the number that corresponds to the
'day, second is the
'number that corresponds to the Time4Work. ie, the
'student available to work
'on Tuesday between 8 and 8:30 will be at the position
'work(2,1)
'For i = 1 To 7
' For n = 1 To 31
' if n=31 then
' sqlstr = SELECT [First Name] FROM [times] WHERE [Day] = days(i) AND ( [Start Time] <= 22.5 'handles the 22.5 till 23 shift
' datSchedule.RecordSource = sqlstr
' work(i, n) = datschedule.recordsource
' else
' sqlstr = SELECT [First Name] FROM [times] WHERE [Day] = days(i) AND ( [Start Time] <= Time4Work AND [End Time] >= Time4Work(n+1)
' datSchedule.RecordSource = sqlstr
' work(i, n) = datschedule.recordsource
' end if
' Next n
' Next i
End Sub
sorry for messiness, and as always i appreciate any help and suggestions you guys provide me with.
thanks
vlada .:have i mentioned that i am still a newbie to this game? :.