Results 1 to 2 of 2
  1. #1
    rossi45 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2012
    Posts
    12

    Using event to update corresponding fields


    Hey folks,

    I have a form that I have built for data entry. It is tied to a table that is pre-loaded with some data. The data entry person will enter the rest of the data through the form. The data is for construction on a square piece of land that is divided into different sections. Each section of that land gets a record in the table to describe the data about that piece of land. There are 2 sections of the form. The first section enters data of that land before the construction begins and the second section describes data of that land when it is reclaimed after construction after construction has taken place. (i.e. after a number of years, the buildings that will be constructed will be torn down and the land will be reclaimed to the way it once was....or best effort)

    I have the following fields:

    Section 1: Data before construction
    PRE_SOIL is a pre-populated text field. Each record has a value. (It's the soil type of that peice of land)
    PRE_VEG is an empty text field. The data entry person will enter a value for each record. No record will be null. (It's a vegetation descriptor for that piece of land)
    PRE_TERR_UNIT is an empty text field. It will be populated by concatenating PRE_SOIL and PRE_VEG.

    Section2: Data after land has been reclaimed:
    POST_SOIL is an empty text field. Each record has a value.
    POST_VEG is an empty text field. The data entry person will enter a value for each record. No record will be null.
    POST_TERR_UNIT is an emtpy text field. It will be populated by concatenating POST_SOIL and POST_VEG.

    A field to describe the type of construction taken place (i.e. a house, a garage, a driveway, etc):
    DEV_AREA is a pre-populated text field. Each record has either a value or is null.

    So, the data entry person enters values into PRE_VEG, POST_SOIL, POST_VEG. PRE_TERR_UNIT and POST_TERR_UNIT is automatically concatenated from their respective SOIL and VEG fields.

    There is a rule. The rule is that if the land area record does not contain any construction (i.e. The null records in DEV_AREA), then the values for Section 2 will remain the same as the respective values from section 1 (i.e. the POST_SOIL will be the same as PRE_SOIL).

    I want to automatically update those fields using a VBA event script. Given that any blank record in DEV_AREA means that no construction will take place on that land record, I know I can script this. I'm not sure which event will do this for me. Can anyone suggest something?

    It's going to go something like:

    Code:
    If Me.DEV_AREA = "" then
        Me.POST_SOIL = Me.PRE_SOIL
        Me.POST_VEG = Me.PRE_VEG
    Thanks,
    Mike

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,600
    Maybe the form OnCurrent event. That event will trigger when record receives focus.

    The code sample tests for empty string, not Null. The following will handle both:

    If Me.DEV_AREA & "" = "" Then
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Before Update Event Help
    By bklewis in forum Access
    Replies: 8
    Last Post: 03-25-2012, 03:58 PM
  2. 'After update' Event procedure
    By sk88 in forum Access
    Replies: 5
    Last Post: 08-30-2011, 02:51 PM
  3. Before Update Event
    By randolphoralph in forum Programming
    Replies: 0
    Last Post: 06-15-2010, 09:26 AM
  4. Determining cause of Update event
    By RJosephNewton in forum Access
    Replies: 3
    Last Post: 03-25-2010, 04:34 PM
  5. Befor update event
    By wasim_sono in forum Forms
    Replies: 1
    Last Post: 03-24-2006, 07:21 AM

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