Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

validating date field on form with multiple users 1

Status
Not open for further replies.

azalealee

Programmer
Nov 21, 2002
36
AU
Hello

I have a "Hazard Alert" database that requires data entry from both administrators and managers.

Administrators enter a hazard into a form then notify the relevant manager to update the database and take necessary actions.

Managers view the same form and update their section including a target_date of completion. This target_date has to be a required field (ie, leaders cannot update their section without filling in a target date).

The problem I'm having is making the target_date a required field when administrators have to create the record first by entering the hazard. I cannot simply set "Required = Yes" in the table because administrators should not have to set the target_date, only managers.

Thanks for your help in advance.
 
Hi there

the solution to this is to put a check into your code - if Administrators don't have to enter a target date, then when you save, firstly check who is loggged in. If the manager is logged in check the date, otherwise ignore it.

ie

If USER = "Manager" then
'Check here that there is a date
If date valid (ie it's not null) then
Save
else
'Display message to the user and reset the focus back
'on the date without saving
end if
else
Save
end if


Hope this helps!!

Transcend
 
Hi Transcend

I don't have any user accounts set-up as this is a very small database and security isn't an issue. So I can't check whether a user is an administrator or a manager.

Would I be able to have the same code on the after update of another field in the Managers section? ie If managers update the Remedial_Action field, then they have to enter a Target_Date.

I don't really like this solution, but I can't think of another way.
 
Hi there,

You are probably right, if the only way to check if it a manager logged in or an administrator then the only way is to put a check on the date field as soon as any field in the managers section contains any data. Basically you could either as soon as any field in the managers section changes, set a boolean value to true. Then at save time you can put in your check for the date, if the value is true then the date can't be null. Alternatively at save time you could check all the manager section fields to see if any of them have a value and if one does then once again check to see if the date has a value.

Hope this helps

Transcend
 
Another way

As you open the form (and using code) put a flag into the openargs. Then the code of the Load event checks for this flag and either sets must be entered or not...

docmd.openform &quot;forename&quot;,,,,,,,,<openargs>


Vince
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top