Tang
Posts: 14
|
| Posted: 08/05/2004, 10:40 AM |
|
I need help with getting the logic and syntax correct with this function and validation expression. This post is in reference to an earliy post that was very vague. I've written the code now and am wondering how to finish to section of my project up.
This is the function, that I'm assuming I should put in the events file?:
Function Total_TITLE_CD()
Dim fSTART_DATE
Dim fEND_DATE
Dim fTITLE_CD
Set Connection = DBOCM_db
Connection.Open
fSTART_DATE = TBL_DEPLOYED.START_DATE.Value
fEND_DATE = TBL_DEPLOYED.END_DATE.Value
fTITLE_CD = TBL_DEPLOYED.TITLE_CD.Value
SQL = "COUNT TBL_DEPLOYED.TITLE_CD"
FROM "TBL_DEPLOYED"
WHERE ("TBL_DEPLOYED.TITLE_CD" = " & fTITLE_CD & ") AND ("TBL_DEPLOYED.START_DATE">= " & fSTART_DATE &
") AND ("TBL_DEPLOYED.END_DATE"<=" & fEND_DATE & ")
End Function
And this is the Validation expression at the "Before Insert" location:
If Total_TITLE_CD() > 5 Then
TBL_DEPLOYED.Errors.addError("Too many personnel for that title code have already scheduled for those
dates")
End if
The query within the func should produce a total number for the number of employes scheduled for the dates within the form, based on the personnels' title_cd.
The Validation expression should only allow inserting the new record only if there are less than 5 people with that title code scheduled.
I'm really reaching with writing code and I desperately need help.
Thanks, Tang
|