Dear Prodevmg

Thank you very much for the code. But looks like i am either not doing it right 
or i am not understanding it right (coz i am know very very little about VB 
codes)

1. I copied ur code and replaced all the Field 1 to BP_Systolic and Filed 2 to 
BP_Diastolic (which are the names of my fields)
2. Then i put this in the overall form Before update event (not as such the 
property sheet of those particulate fields)
3.Please see the code:


Private Sub BP_Diastolic_BeforeUpdate(Cancel As Integer)
 If IsNull(BP_Systolic) = False And BP_Systolic <> "" Then
        If IsNull(BP_Diastolic) = True Or BP_Diastolic = "" Then
            
            BP_Diastolic.SetFocus
            BP_Diastolic.BackColor = vbYellow
            
            MsgBox "You must enter a value in BP_Diastolic", vbCritical
            Exit Sub
            
        Else
                
            BP_Diastolic.SetFocus
            BP_Diastolic.BackColor = vbWhite
        
        End If
    End If
 
End Sub
5. So i deleted one end sub form the code @ the end and rigth after that, field 
2 became yellow. So i entered data
6. it gave me run-time error msg ..Read..." You must save teh field before you 
execute the goToControl action, the goToControl method, or the setFocus method.
7. so i hit debug...it highlighted the BP_Diastolic.Setfocus (which is after 
Else)
Please help..i have made a mistake with the code copying?
Is there a easier way to do this
 4. Then i closed the sheet and went to form view. it said compile error: the 
messg read" Only comments may appear after end subs, end function or End 
property.



________________________________
From: Lonnie Johnson <[email protected]>
To: [email protected]
Sent: Wed, April 28, 2010 6:57:00 PM
Subject: Re: [ms_access] Validation Rule : If you fill in Field1, Field2 is 
required also..NOT WORKING

  
You could put this in your form's Before Update event.

    If IsNull(FIELD1) = False And FIELD1 <> "" Then
        If IsNull(FIELD2) = True Or FIELD2 = "" Then
            
            FIELD2.SetFocus
            FIELD2.BackColor = vbYellow
            
            MsgBox "You must enter a value in Field2", vbCritical
            Exit Sub
            
        Else
                
            FIELD2.SetFocus
            FIELD2.BackColor = vbWhite
        
        End If
    End If

____________ _________ _________ __
From: microaccess80 <microaccess80@ yahoo.com>
To: ms_acc...@yahoogrou ps.com
Sent: Tue, April 27, 2010 12:58:28 PM
Subject: [ms_access] Validation Rule : If you fill in Field1, Field2 is 
required also..NOT WORKING

  
Hello

([Field1] Is Null) OR ([Field2] Is Not Null)is not working for "If you fill in 
Field1, Field2 is required" in Both Tables and Forms

I have Fiedl 1 as Blood Pressure Systolic
I have Field 2 as Blood Pressure Diastolic 
Both fielda are "number" format 

I am not very good with codes, so i am trying validation rules. If simple VBA 
codes can work for this, than i can do that. Please help. I am very much in 
need. Really hoping for a reply

[Non-text portions of this message have been removed]





      

[Non-text portions of this message have been removed]

Reply via email to