Results 1 to 3 of 3
  1. #1
    alosbanos is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    2

    How to clear a field when another field is Null

    Hello,



    This is a newbie question, but I have a form with field [Status]. When [Status] is set to "Will Attend" I can input the country of birth in field [Country_Birth]. My question is there something where if [Status] field is set back to null field [Country_Birth] will automatically clear?

    Thank you,
    Asuncion

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Click on your Status field.
    Open the Property Sheet.
    Click the Event Tab.
    Click in the Lost Focus Row.
    Click the [...] on the right.
    Choose Code Builder if prompted.

    The code window that opens will look something like this:

    Code:
     
    Private Sub Status_LostFocus()
     
    End Sub
    I haven't tested this code - but let me know if you have problems with it.

    Type something like this between those two lines:
    Code:
     
    Me.Status.SetFocus
    If Len(Me.Status) < 1 Then
        Me.Country_Birth.SetFocus
        Me.Country_Birth = ""
    End If

  3. #3
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,071
    Depending on the Actual Value of me.status this will not work as expected. If me.status is null len(me.status) will return null. Use this instead this will account for all possibilities.

    If IsNull(me.status) or len(me.status) < 1 Then

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

Similar Threads

  1. Null field blank
    By brobb56 in forum Reports
    Replies: 3
    Last Post: 09-26-2011, 12:15 PM
  2. If Field is Null - Then Use Data from Other Field
    By KrenzyRyan in forum Queries
    Replies: 4
    Last Post: 06-10-2011, 12:12 AM
  3. Null field message
    By jpkeller55 in forum Access
    Replies: 3
    Last Post: 09-03-2010, 10:45 AM
  4. Clear a Field OnClick
    By eww in forum Forms
    Replies: 3
    Last Post: 08-19-2010, 01:55 PM
  5. clear field values
    By surrendertoo in forum Queries
    Replies: 0
    Last Post: 02-23-2008, 10:57 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