Delete Field Data if Another Field Has Data

  • Thread starter hobbit2612 via AccessMonster.com
  • Start date
H

hobbit2612 via AccessMonster.com

Hi,

I wonder if someone may be able to help me please.

I have a subform called sfrmJobs which contains amongst others two fields,
one called 'Predicted Date', the other ,'Actual Date'.

What I would like to be happen is, if a date is keyed into the 'Actual Date'
box, any date keyed into the 'Predicted Date' text box is deleted and then
locks the 'Predicted Date' field for that record, but, to be honest I haven't
got a clue where to start, or indeed whether it's possible.

Could someone possibly help me put with this problem please?

Many thanks

Chris
 
K

Ken Snell

You could use code like this for the Actual Date control's AfterUpdate
event:

Private Sub Actual_Date_AfterUpdate()
Dim blnLock As Boolean
blnLock = (Me.[After Update].Value & "" <> "")
If blnLock = True Then Me.[Predicted Date].Value = Null
Me.[Predicted Date].Locked = blnLock
Me.[Predicted Date].Enabled = Not blnLock
End Sub


You also will need to use this code for the form's Current event:

Private Sub Form_Current()
blnLock = (Me.[After Update].Value & "" <> "")
Me.[Predicted Date].Locked = blnLock
Me.[Predicted Date].Enabled = Not blnLock
End Sub
 
H

hobbit2612 via AccessMonster.com

Hi Ken,

Firstly I can't believe how quickly you came up with the coding, amazing!!

I made some very minor chnages to the code and changed (Me.[After Update] to
(Me.ActualDate and it works a treat.

Thank you so much for your time and help it really is appreciated.

Regards

Chris

Ken said:
You could use code like this for the Actual Date control's AfterUpdate
event:

Private Sub Actual_Date_AfterUpdate()
Dim blnLock As Boolean
blnLock = (Me.[After Update].Value & "" <> "")
If blnLock = True Then Me.[Predicted Date].Value = Null
Me.[Predicted Date].Locked = blnLock
Me.[Predicted Date].Enabled = Not blnLock
End Sub

You also will need to use this code for the form's Current event:

Private Sub Form_Current()
blnLock = (Me.[After Update].Value & "" <> "")
Me.[Predicted Date].Locked = blnLock
Me.[Predicted Date].Enabled = Not blnLock
End Sub
[quoted text clipped - 15 lines]
 
Top