Results 1 to 5 of 5
  1. #1
    goakley is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    9

    What event do I use if I want to have information from two fields

    I have a record that has a field called "PG". Every "PG" has different standards depending on what quarter it is in. There is a field called "Quarter" in the record along with a field called "PC". The "PC" field is the "PG" field plus the "Quarter" field. (all are text fields). I would like the "PC" field to be automatically entered once the other 2 fields have their values. Do I use the formula

    [PC] = [PG] + [Quarter]



    And do I put that as an event, and if so, which one.

    I hope my questions are not too stupid.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    Why bother saving the concatenated value? It can be calculated whenever needed. You can even do the calculation in a Calculated field in table.

    Otherwise, try the BeforeUpdate event of form or table data macro.

    Me!PC = Me.PG & Me.Quarter
    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.

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    June! you type too fast........


    @ OP
    You would need to use some VBA in an event procedure to update the field if you are managing this update in a form.
    Me.PC.Value = Me.PG.Value & Me.Quarter.Value
    or
    Me.PC.Value = Me.PG.Value & "_" & Me.Quarter.Value
    If you want to include some text to seperate the two values.

    Generaly, you do not want to store this information in a table and would just create it on the fly, as needed.

    You could put the whole thing in a query object and include said query when you want to display the concatenated value.

    You would create an alias in a new query field.
    MyNewAlias: [TableName].[PG] & "_" & [TableName].[Quarter]

    and also include the ID field, the PG field, and the Quarter field.

    In the ID and Quarter field you would include criteria like
    Is Not Null

    To make sure the record was retrieved only when there was a value in both PG and Quarter. You would then join this new query to an existing query in the ID field using a LEFT JOIN, new query on the RIGHT.

    If you plan on having users do searches on this concatenated value then go ahead and store it in a field in a table. In other words, if you are going to query the GP and Quarter together and often, because this is how users will interact with the data and this is how they recognize it and won’t search only on GP or Quarter, store the combined fields in its own field.

  4. #4
    goakley is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    9
    Quote Originally Posted by June7 View Post
    Why bother saving the concatenated value? It can be calculated whenever needed. You can even do the calculation in a Calculated field in table.

    Otherwise, try the BeforeUpdate event of form or table data macro.

    Me!PC = Me.PG & Me.Quarter
    Thank you. I will try that. I do have it set up as a calculated field in the table because I needed a way to make it unique. However, when I tried to use it in a query I was told I could not use calculated fields for what I wanted to do. So, I was trying to get it to concatenate the field when the entry was made and the PG and the Quarter had values. My employees enter different type of documents. They are called programs. They have a standard of quantity and quality that they must meet on each program. These standards change each quarter. I need to calculate if they met those standards and how much time was spent on them out of their total (YTD) hours. So, because each program has a different standard each quarter, I must distinguish a program done in Qtr 1, between the same program done in Qtr2. So I decided to give them program codes that would make them unique when I totaled the yearly production. I do that by concatenated the program and the quarter. The time spent on that program in that quarter divided by total time gives them their weight. Then their weight determines how much of their efficiency gets counted toward their meeting standards. I have a long way to go. I have a final formula to use but I need all the totals.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    Cannot save value to a calculated field. That defeats their purpose.

    What were you doing that query could not use calculated field? I am aware of calculated fields but have not made use of them so they might have limitations I am not aware of.
    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. Replies: 4
    Last Post: 02-27-2014, 03:39 PM
  2. Fill multiple fields with the same information
    By ben_jamin in forum Access
    Replies: 4
    Last Post: 07-23-2013, 07:24 AM
  3. Table Design: Fields with duplicate information
    By snowboarder234 in forum Access
    Replies: 3
    Last Post: 10-17-2012, 10:43 AM
  4. Using event to update corresponding fields
    By rossi45 in forum Forms
    Replies: 1
    Last Post: 05-02-2012, 01:29 AM
  5. Information message on current event
    By justauser in forum Forms
    Replies: 5
    Last Post: 02-07-2012, 12:15 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