Conditional Formatting not working on Subform

You are missing the right parentheses from the DSum function and then you also have a strange calculation there with the equal sign and all. I changed to;
Code:
If DSum("[PlannedHours]", "EmployeeWeeklyActivityCommentstbl", "[CommentsDateTimeStamp] Between ([CommentsDateTimeStamp])+7-Weekday([CommentsDateTimeStamp],2) - 7 And ([CommentsDateTimeStamp])+7-Weekday([CommentsDateTimeStamp],2)[COLOR=red])[/COLOR] [COLOR=red][B]+ Me.PlannedHours[/B][/COLOR] > 34.15 Then
 
Last edited:
Hi Bob,

thank you ... but now I'm getting a Compile Error: Expected: list separator or )

I have tried but no luck ....
 
Here is the code that gives me the error

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
  If (Me.PlannedHours) <= 0 Or IsNull(Me.SubActivityDetails) Then
      MsgBox ("You must enter your planned hours and provide a description of the activity"), 0, "Weekly Schedule Control System"
      Cancel = True
  End If
'If DSum("[PlannedHours]", "EmployeeWeeklyActivityCommentstbl", "[CommentsDateTimeStamp] Between ([CommentsDateTimeStamp])+7-Weekday([CommentsDateTimeStamp],2) - 7 And ([CommentsDateTimeStamp])+7-Weekday([CommentsDateTimeStamp],2) =  " & Me.CurRptWeekendDatetxt) + Me.PlannedHours > 34.15 Then
 If DSum("[PlannedHours]", "EmployeeWeeklyActivityCommentstbl", "[CommentsDateTimeStamp] Between ([CommentsDateTimeStamp])+7-Weekday([CommentsDateTimeStamp],2) - 7 And ([CommentsDateTimeStamp])+7-Weekday([CommentsDateTimeStamp],2))  + Me.PlannedHours > 34.15 Then
          MsgBox ("You have exceeded your planned hours limit of 34.15"), 0, "Weekly Schedule Control System"
      Cancel = True
  End If
 
End Sub
 
Just tried this and got rid of the syntax error and now I'm getting a type mismatch ....

Code:
If DSum("[PlannedHours]", "EmployeeWeeklyActivityCommentstbl", "[CommentsDateTimeStamp] Between ([CommentsDateTimeStamp])+7-Weekday([CommentsDateTimeStamp],2) - 7 And ([CommentsDateTimeStamp])+7-Weekday([CommentsDateTimeStamp],2))" + Me.PlannedHours > 34.15) Then
 
ITS ALIVE ! ! ! ! ! muhahahaha :D:D:D:D

Code:
If DSum("[PlannedHours]", "EmployeeWeeklyActivityCommentstbl", "[CommentsDateTimeStamp] Between ([CommentsDateTimeStamp])+7-Weekday([CommentsDateTimeStamp],2) - 7 And ([CommentsDateTimeStamp])+7-Weekday([CommentsDateTimeStamp],2) = " & Me.CurRptWeekendDatetxt + Me.PlannedHours > 34.15) Then

did the trick!

Thank you for all your help Bob ... I really appreciate!
 
Final working code is ......

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
  If (Me.PlannedHours) <= 0 Or IsNull(Me.SubActivityDetails) Then
      MsgBox ("You must enter your planned hours and provide a description of the activity"), 0, "Weekly Schedule Control System"
      Cancel = True
  End If
 If DSum("[PlannedHours]", "EmployeeWeeklyActivityCommentstbl", "[CommentsDateTimeStamp] Between ([CommentsDateTimeStamp])+7-Weekday([CommentsDateTimeStamp],2) - 7 And ([CommentsDateTimeStamp])+7-Weekday([CommentsDateTimeStamp],2) = " & Me.CurRptWeekendDatetxt + Me.PlannedHours > 34.15) Then
          MsgBox ("You have exceeded your planned hours limit of 34.15"), 0, "Weekly Schedule Control System"
      Cancel = True
  End If
 
End Sub
 

Users who are viewing this thread

Back
Top Bottom