Hi,
I have a bespoke data validation system set up for one of my forms.
The data validation defines which controls must be popolated for a project dependant on the project status (which is itself a control). The controls to be checked are variable (i.e someone with admin permissiong could go into the database and modify the list of checked controls).
So what I end up with is a two tables:
tblStatusValidationLevels, which contains the validation levels assigned to each status
and
tblFieldValdationLevels that has the following fields
ControlName (the name of the control on the form that is to be checked)
DisplayName (A user friendly version of the name for error messages)
ValidationLevel (the validation level of that control)
What I want the code to do is
1. Check the status and look up the status security value
2. Check each record th the tblFieldValidation recordset and if the validation level is equal or less than that of the status check that a value is entered in the field
3. Display a message at the end to show the user the missing fields.
Below is what I have so far. I can't figure out how to use a control name in a variable to check the value of that control.
If anyone can help it would be hugely appreciated
I have a bespoke data validation system set up for one of my forms.
The data validation defines which controls must be popolated for a project dependant on the project status (which is itself a control). The controls to be checked are variable (i.e someone with admin permissiong could go into the database and modify the list of checked controls).
So what I end up with is a two tables:
tblStatusValidationLevels, which contains the validation levels assigned to each status
and
tblFieldValdationLevels that has the following fields
ControlName (the name of the control on the form that is to be checked)
DisplayName (A user friendly version of the name for error messages)
ValidationLevel (the validation level of that control)
What I want the code to do is
1. Check the status and look up the status security value
2. Check each record th the tblFieldValidation recordset and if the validation level is equal or less than that of the status check that a value is entered in the field
3. Display a message at the end to show the user the missing fields.
Below is what I have so far. I can't figure out how to use a control name in a variable to check the value of that control.
Code:
Dim DataValNum As Integer
'get the status validation level
DataValNum = DLookup("[ValidLevel]", "tblStatusValidationLevels", "[StatusID]=" & Me.Status)
msg = "The following Data is missing:" & vbcr
Dim rcd As DAO.recordset
Set rcd = CurrentDb.OpenRecordset("tblFieldValdationLevels", dbOpenDynaset)
rcd.MoveFirst
do until rcd.EOF
' Check the security level of the fields (level 0 means do not check)
If rcd("ValidationLevel").Value <= DataValNum And rcd ("ValidationLevel").Value <> 0 Then
'***********************************************
'Check the control. How?
'*************************************************
msg = msg & rcd("DisplayName").value & vbcr
dataOK = false
End If
rcd.movenext
Loop
if DataOk = false then
..... etc
If anyone can help it would be hugely appreciated