Alright. I'm using Access97, and following this intro is code in my 'calendar' form (thanks FAQs) to fill in each textbox representing a day of the month, AND the code to fill in the box if the strSQL statement returned one or more results. However - it only ever fills up the boxes 2 and 3 or 31 and 32, depending on the month.
----------------------------------
Private Function filldates()
Dim curday As Variant, curbox As Integer
curday = DateSerial(Year(Me![FirstDate]), Month(Me![FirstDate]), 1) 'Get the first day of the chosen month
Do Until DatePart("w", curday, vbSunday) = 1 ' count back til Sunday
curday = DateAdd("d", -1, curday)
Loop
For curbox = 0 To 41 'need to loop through 42 textboxes
Me("D" & curbox) = Day(DateAdd("d", curbox, curday))
Call boxes(curday, curbox)
If Month(DateAdd("d", curbox, curday)) = Month(Me!FirstDate) Then
Me("D" & curbox).Visible = True
Else
Me("D" & curbox).Visible = False
End If
Next curbox
Me.Repaint 'display changes
End Function
---------------------------
And the boxes function to fill in the background.
---------------------------
Public Function boxes(curday As Variant, curbox As Integer)
Dim db1 As Database
Dim rst As Recordset
Dim temp2 As Date
Dim strSQL As String
Dim temp As String
temp2 = DateSerial(Year(Me![FirstDate]), Month(Me![FirstDate]), curbox)
strSQL = "SELECT * FROM tblSummary1 WHERE ShipDate = #" & temp2 & "# OR BatchMakeDate = #" & temp2 & "# OR NYStdDate = #" & temp2 & "# OR NYMassDate = #" & temp2 & "# OR ComponentsDueBy = #" & temp2 & "#;"
Set db1 = CurrentDb
Set rst = db1.OpenRecordset(strSQL)
If rst.RecordCount <> 0 Then
Me("D" & curbox).BackColor = 2500
End If
End Function
Does anybody know why it fills up those special boxes regardless of whether or not they're filled? Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum immane mittam.
----------------------------------
Private Function filldates()
Dim curday As Variant, curbox As Integer
curday = DateSerial(Year(Me![FirstDate]), Month(Me![FirstDate]), 1) 'Get the first day of the chosen month
Do Until DatePart("w", curday, vbSunday) = 1 ' count back til Sunday
curday = DateAdd("d", -1, curday)
Loop
For curbox = 0 To 41 'need to loop through 42 textboxes
Me("D" & curbox) = Day(DateAdd("d", curbox, curday))
Call boxes(curday, curbox)
If Month(DateAdd("d", curbox, curday)) = Month(Me!FirstDate) Then
Me("D" & curbox).Visible = True
Else
Me("D" & curbox).Visible = False
End If
Next curbox
Me.Repaint 'display changes
End Function
---------------------------
And the boxes function to fill in the background.
---------------------------
Public Function boxes(curday As Variant, curbox As Integer)
Dim db1 As Database
Dim rst As Recordset
Dim temp2 As Date
Dim strSQL As String
Dim temp As String
temp2 = DateSerial(Year(Me![FirstDate]), Month(Me![FirstDate]), curbox)
strSQL = "SELECT * FROM tblSummary1 WHERE ShipDate = #" & temp2 & "# OR BatchMakeDate = #" & temp2 & "# OR NYStdDate = #" & temp2 & "# OR NYMassDate = #" & temp2 & "# OR ComponentsDueBy = #" & temp2 & "#;"
Set db1 = CurrentDb
Set rst = db1.OpenRecordset(strSQL)
If rst.RecordCount <> 0 Then
Me("D" & curbox).BackColor = 2500
End If
End Function
Does anybody know why it fills up those special boxes regardless of whether or not they're filled? Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum immane mittam.