G
Guest
Hi all
Sorry about this but I realy cant get my head around the use of DSUM to acheive my goal.
I have a single table whre the user records the duration (in quarter days eg 0.25, 0.50, 0.5 or 1.00) spent on a task against a date.
the feild on the table are
DateID Auto number
MyDate Date
Duration Number (Double)
Task Text
Note Memo
Table name is tblDate
the form has a bound control used for this and includes all the above
the form name is frmDate
In the before update event for the control - but I get the same result if I use the same for the form update event
My code is as follows
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim dblSubTotal As Double, dblTotal As Double
dblSubTotal = DSum("Duration", "tblDate", "[Date]= " & Forms!frmdate!Date)
dblTotal = Me!Duration + dblSubTotal
If dblTotal > 1 Then
Cancel = True
MsgBox "Entry cancelled"
End If
End Sub
The result is 'Invalid use of Null'
Can any one please help - Im pretty new to access and this has me stumped - all i want to do is stop people entering to many tasks with to much time to a single date. should be simple but Im afraid I cant figure it out.
Many thanks in advance
GreenBoy
Sorry about this but I realy cant get my head around the use of DSUM to acheive my goal.
I have a single table whre the user records the duration (in quarter days eg 0.25, 0.50, 0.5 or 1.00) spent on a task against a date.
the feild on the table are
DateID Auto number
MyDate Date
Duration Number (Double)
Task Text
Note Memo
Table name is tblDate
the form has a bound control used for this and includes all the above
the form name is frmDate
In the before update event for the control - but I get the same result if I use the same for the form update event
My code is as follows
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim dblSubTotal As Double, dblTotal As Double
dblSubTotal = DSum("Duration", "tblDate", "[Date]= " & Forms!frmdate!Date)
dblTotal = Me!Duration + dblSubTotal
If dblTotal > 1 Then
Cancel = True
MsgBox "Entry cancelled"
End If
End Sub
The result is 'Invalid use of Null'
Can any one please help - Im pretty new to access and this has me stumped - all i want to do is stop people entering to many tasks with to much time to a single date. should be simple but Im afraid I cant figure it out.
Many thanks in advance
GreenBoy