Results 1 to 4 of 4
  1. #1
    ekulz is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2012
    Posts
    3

    Question Validation rule in relation to another field name?

    Hi,


    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.

    I use access 2007 or 2010 depending what computer I'm using.

    Thanks, Luke

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    In the AfterUpdate Event for the fieldname1 containing the serial number,

    Code:
    If IsNull(me.fieldname1) Then
    me.OtherFieldName = Null
    Else
    Me.OtherFieldName = 1
    End If

  3. #3
    ekulz is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2012
    Posts
    3
    Quote Originally Posted by alansidman View Post
    In the AfterUpdate Event for the fieldname1 containing the serial number,

    Code:
    If IsNull(me.fieldname1) Then
    me.OtherFieldName = Null
    Else
    Me.OtherFieldName = 1
    End If
    Hi,
    Thanks for your answer but I'm not sure that's what I'm looking for. Where you said OtherFieldName = Null (otherfieldname being quantity) I think i want to rephrase that. The quantity can be either zero, or any number other than one to make fieldname1 (serialnumber) blank.

    Hopefully I made myself a bit clearer

  4. #4
    ekulz is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2012
    Posts
    3
    Nevermind, solved it myself.
    Code:
    ([Quantity]=1) Or ([SerialNumber] Is Null)

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Validation rule for a month field
    By Alliana Gray in forum Access
    Replies: 7
    Last Post: 08-11-2011, 12:41 PM
  2. Validation Rule
    By Megan in forum Access
    Replies: 1
    Last Post: 11-05-2010, 09:45 AM
  3. Validation Rule
    By smitstev in forum Access
    Replies: 5
    Last Post: 06-30-2009, 09:58 AM
  4. Referencing table data in field validation rule
    By toad848 in forum Database Design
    Replies: 3
    Last Post: 03-19-2009, 07:03 AM
  5. Validation rule for a text field
    By wasim_sono in forum Forms
    Replies: 4
    Last Post: 03-14-2006, 11:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums