1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Dim strTblName As String, strValidRule As String
Dim strValidText As String
Dim intX As Integer
strTblName = "Employees"
strValidRule = "EndDate > StartDate"
strValidText = "Enter an EndDate that is later than the StartDate."
intX = SetTableValidation(strTblName, strValidRule, strValidText)
Function SetTableValidation(strTblName As String, _
strValidRule As String, strValidText As String) _
As Integer
Dim dbs As Database, tdf As TableDef
Set dbs = CurrentDb
Set tdf = dbs.TableDefs(strTblName)
tdf.ValidationRule = strValidRule
tdf.ValidationText = strValidText
End Function |
Partager