HELP with coding

  • Thread starter Thread starter Raj
  • Start date Start date
R

Raj

I need help in coding with 3 field I have [MRC],[QRC] and
[OTC].
If [MRC] or [QRC] has a value entered and someone tries
to enter a value in [OTC] or if you have a value in
[OTC] and try to enter a value in [MRC] or [QRC] I need
a message box that says "You can not have a [ORC] and
you can have [MRC] or [QRC] and vice versa.

Thank you in advance.
Raj
 
You would use the BeforeUpdate events to test for this and stop it:

Private Sub MRC_BeforeUpdate(Cancel As Integer)
If Len(Me.OTC.Value & "") > 0 Then
MsgBox "A value has already been entered in OTC." & _
" You cannot enter a value here, too.", vbExclamation, _
"Entry Not Allowed!"
Cancel = True
Me.MRC.Undo
End If
End Sub

Private Sub QRC_BeforeUpdate(Cancel As Integer)
If Len(Me.OTC.Value & "") > 0 Then
MsgBox "A value has already been entered in OTC." & _
" You cannot enter a value here, too.", vbExclamation, _
"Entry Not Allowed!"
Cancel = True
Me.QRC.Undo
End If
End Sub

Private Sub OTC_BeforeUpdate(Cancel As Integer)
If Len(Me.MRC.Value & "") > 0 Then
MsgBox "A value has already been entered in MRC." & _
" You cannot enter a value here, too.", vbExclamation, _
"Entry Not Allowed!"
Cancel = True
Me.OTC.Undo
ElseIf Len(Me.QRC.Value & "") > 0 Then
MsgBox "A value has already been entered in QRC." & _
" You cannot enter a value here, too.", vbExclamation, _
"Entry Not Allowed!"
Cancel = True
Me.OTC.Undo
End If
End Sub
 
Ken,
Thank you very much..
-----Original Message-----
You would use the BeforeUpdate events to test for this and stop it:

Private Sub MRC_BeforeUpdate(Cancel As Integer)
If Len(Me.OTC.Value & "") > 0 Then
MsgBox "A value has already been entered in OTC." & _
" You cannot enter a value here, too.", vbExclamation, _
"Entry Not Allowed!"
Cancel = True
Me.MRC.Undo
End If
End Sub

Private Sub QRC_BeforeUpdate(Cancel As Integer)
If Len(Me.OTC.Value & "") > 0 Then
MsgBox "A value has already been entered in OTC." & _
" You cannot enter a value here, too.", vbExclamation, _
"Entry Not Allowed!"
Cancel = True
Me.QRC.Undo
End If
End Sub

Private Sub OTC_BeforeUpdate(Cancel As Integer)
If Len(Me.MRC.Value & "") > 0 Then
MsgBox "A value has already been entered in MRC." & _
" You cannot enter a value here, too.", vbExclamation, _
"Entry Not Allowed!"
Cancel = True
Me.OTC.Undo
ElseIf Len(Me.QRC.Value & "") > 0 Then
MsgBox "A value has already been entered in QRC." & _
" You cannot enter a value here, too.", vbExclamation, _
"Entry Not Allowed!"
Cancel = True
Me.OTC.Undo
End If
End Sub


--

Ken Snell
<MS ACCESS MVP>

I need help in coding with 3 field I have [MRC],[QRC] and
[OTC].
If [MRC] or [QRC] has a value entered and someone tries
to enter a value in [OTC] or if you have a value in
[OTC] and try to enter a value in [MRC] or [QRC] I need
a message box that says "You can not have a [ORC] and
you can have [MRC] or [QRC] and vice versa.

Thank you in advance.
Raj


.
 
Ken,
If you are still there. How can this code be changed to
see if a date has been entered before it will let you
another..
[researchdate], [handoffdate], [followupdate],
[resolvedate]
[resdate] must be filled in before you can enter
[handoffdate]
[handoffdate] must be filled in if [followupdate] or
[resolvedate] are entered
Thank you,
Raj
 
Use the code that I provided as the template and modify it for the different
control names. Put code on the BeforeUpdate event of each of the date
controls.
 
Thanks again..
-----Original Message-----
Use the code that I provided as the template and modify it for the different
control names. Put code on the BeforeUpdate event of each of the date
controls.

--

Ken Snell
<MS ACCESS MVP>


Ken,
If you are still there. How can this code be changed to
see if a date has been entered before it will let you
another..
[researchdate], [handoffdate], [followupdate],
[resolvedate]
[resdate] must be filled in before you can enter
[handoffdate]
[handoffdate] must be filled in if [followupdate] or
[resolvedate] are entered
Thank you,
Raj


.
 
Back
Top