Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2012

    Unanswered: Creating a validation rule in relation to another fieldname?

    As the title says, I was wondering how to create a validation rule in relation to another fieldname in the same table?
    for example, the first field line is the serial number, and when something is entered for the serial number the OTHER field line (which is quantity) needs to be 1, otherwise it stays blank.


    edit: by the way, this is access 2007 (or 2010, my uni uses that)
    Last edited by ekulz; 04-28-12 at 02:51. Reason: extra details

  2. #2
    Join Date
    Jun 2005
    Richmond, Virginia USA
    Provided Answers: 19
    Private Sub SerialNumberTextBox_AfterUpdate()
     If Nz(Me.SerialNumberTextBox, "") <> "" Then
      Me.TargetTextBox = 1
      Me.TargetTextBox = Null
     End If
    End Sub
    Strictly speaking, this is a Calculated Field, and as such should not really be Bound to a Field in the underlying Table. If the TargetField is Bound, the above code will do. If it is Unbound, you will need to place the same code in the Form_Current event, as well.

    Linq ;0)>
    Hope this helps!

    The problem with making anything that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts