- Aug 24, 2000
- 4,153
- 4
- 81
OK, I've been Googling my butt off but I can't seem to find exactly what I need.
I have a very simple Access data base I am working on for tracking training tasks.
I have a form I've created for updating training records and it has the following fields:
Employee: (from Employees table) [TrainingRecords.EmpName]
Assigned Task: (from Tasks table) [TrainingRecords.EmpTask]
Start Date: (date) [TrainingRecords.TNGStart]
Employee Initials: (text [3]) [TrainingRecords.EmpIni]
Trainer Initials: (text [3]) [TrainingRecords.TrnrIni]
Tasks Completed: (yes/no checkbox) [TrainingRecords.TNGCmpl]
Completion Date: (autodate when Tasks Completed is checked) [TrainingRecords.CmplDate]
So far I have the auto-date thing working when the [TNGCmpl] box gets checked by using the following code:
----------------
Private Sub TNGCmpl_Click()
If Me.TNGCmpl = True Then
Me.CmplDate = Date
Else
'Optional - clear date if check box is cleared
Me.CmplDate = Null
End If
End Sub
----------------
What I want to do now is before allowing the [TNGCmpl] box to be checked, validate [EmpIni] and [TrnrIni] for Null OR Empty values (technically they're not the same).
Basically it would go something to the effect of this:
If [EmpIni] or [TrnrIni] are Null OR Empty Then
Cancel the operation and display an error message.
In other words, do not allow someone to click the completed box on the form without entering employee initials and trainer initials first.
I know this has got to be simple but I've not found a way within Access that works for me yet.
Can someone smarter than I please take a moment and hammer out a quick snippet of code that will get this done for me?
Thanks!
-JR
I have a very simple Access data base I am working on for tracking training tasks.
I have a form I've created for updating training records and it has the following fields:
Employee: (from Employees table) [TrainingRecords.EmpName]
Assigned Task: (from Tasks table) [TrainingRecords.EmpTask]
Start Date: (date) [TrainingRecords.TNGStart]
Employee Initials: (text [3]) [TrainingRecords.EmpIni]
Trainer Initials: (text [3]) [TrainingRecords.TrnrIni]
Tasks Completed: (yes/no checkbox) [TrainingRecords.TNGCmpl]
Completion Date: (autodate when Tasks Completed is checked) [TrainingRecords.CmplDate]
So far I have the auto-date thing working when the [TNGCmpl] box gets checked by using the following code:
----------------
Private Sub TNGCmpl_Click()
If Me.TNGCmpl = True Then
Me.CmplDate = Date
Else
'Optional - clear date if check box is cleared
Me.CmplDate = Null
End If
End Sub
----------------
What I want to do now is before allowing the [TNGCmpl] box to be checked, validate [EmpIni] and [TrnrIni] for Null OR Empty values (technically they're not the same).
Basically it would go something to the effect of this:
If [EmpIni] or [TrnrIni] are Null OR Empty Then
Cancel the operation and display an error message.
In other words, do not allow someone to click the completed box on the form without entering employee initials and trainer initials first.
I know this has got to be simple but I've not found a way within Access that works for me yet.
Can someone smarter than I please take a moment and hammer out a quick snippet of code that will get this done for me?
Thanks!
-JR
Last edited: