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!

Help with before update code..

Status
Not open for further replies.

realstandman

IS-IT--Management
Oct 29, 2003
87
US
I am trying to validate some fields based on other fields. I have two fields that if they are > o then at least one of three other fields needs to have data. This is where I am now. The three fields are date fields and I am using access 2003 and access 2000 as my default.

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.txtHCFA Or Me.txtUB92 > 0 Then

'This is where I need to check to see if me.txtOldestDate or me.txtOldestDatePTP
'or me.txt214 has data. I only need at least on of these three to have data.


Else
MsgBox ("You must enter in an Oldest date")
End If
Me.txtOldestDate.SetFocus

Cancel = 1
Exit Sub

Any help is greatly appriciated. Thanks Stan


Don't think and the solution will come.
 
Hi Stan!

Why not check the sum of the three dates? If it is 0, then no date has been entered...

Code:
If SUM(Me.txtOldestDate.Value + Me.txtOldestDatePTP.Value + Me.txt214.Value) = 0 Then     'User didn't enter an oldest date
     Msgbox "You must enter in an Oldest date",vbInformation,"Missing Date"
     Docmd.CancelEvent
End If

Tom

Born once die twice; born twice die once.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top