Results 1 to 8 of 8
  1. #1
    laotzu is offline Novice
    Windows 7 Access 2007
    Join Date
    Apr 2010
    Posts
    1

    Updting a field based on another field

    I'm really new to Access and I have a very basic question. Basically, I have one field that stores a number value, and another field that stores yes/no. I want to yes/no field to update to yes automatically when the number field exceeds 10.



    Do I use a query to do this or what? I am completely lost.

  2. #2
    Evgeny's Avatar
    Evgeny is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2010
    Posts
    85
    Hey mate, im not an expert but this vba code should work for you (hit tab after you enter the value)

    Private Sub Number_AfterUpdate()

    If Me.Number.Value > = 10 Then
    Me.Status = "Yes"
    Else
    Me.Status = "No"

    DoCmd.Requery
    Me.Refresh

    End If
    End Sub

    Place it in your first field AfterUpdate code.

  3. #3
    Evgeny's Avatar
    Evgeny is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2010
    Posts
    85
    It worked when i tested it, please post if it helped you.
    Regards

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    You really should not store a calculated value in this case. Just use a query to create the yes/no results you need every time.

  5. #5
    Evgeny's Avatar
    Evgeny is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2010
    Posts
    85
    Oh ok... just trying to help with what i know What would be an example of the query?

    Regards

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Something like:
    SELECT NumField, IIF( [NumField] > 10, "Yes", "No") As OtherField

  7. #7
    Evgeny's Avatar
    Evgeny is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2010
    Posts
    85
    is it preferred or the right way of doing it?

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    This link should help answer that question: http://allenbrowne.com/casu-14.html

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

Similar Threads

  1. Lock Field based on other field value
    By diane802 in forum Access
    Replies: 5
    Last Post: 01-14-2010, 10:40 AM
  2. Autofill field based on autonumber field
    By frevilla in forum Forms
    Replies: 1
    Last Post: 09-11-2009, 02:50 AM
  3. Total based on Formula based on field value
    By cjbuechler in forum Reports
    Replies: 15
    Last Post: 07-10-2009, 09:56 AM
  4. Select a certain field of a record based on ID
    By cesarone82 in forum Access
    Replies: 3
    Last Post: 06-06-2009, 01:16 PM
  5. query - criteria based on another row field value
    By techexpressinc in forum Queries
    Replies: 1
    Last Post: 05-29-2009, 04:17 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