Results 1 to 6 of 6
  1. #1
    Annnnn is offline Novice
    Windows 10 Access 2007
    Join Date
    Feb 2018
    Posts
    17

    Adding text to table using a formula

    Hi,



    I'm not sure if what I want is possible but here I go.

    I have a very simple table and have a form that I can use to add information to this table, and that all works fine, but subsequently I want to create a "sample_name" within this form and add
    it to my table.
    To create the Sample_name I use a formula =Replace([Patient_name],"-","") but when I save it it does not store the information in the main table. (so, everything is added to the table but the sample_name)

    In the main table I have a column that is called sample_name but I cannot seem to link it to the field in the form.

    I Hope it's a bit clear what i main

    Tnx

    Cheers

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    Replace is not really a formula but rather an 'action' event.
    It wants to physically alter the data, not display data.

    so either:
    run the replace action to fix the data, (update query)
    or
    to display data, youd want something like:

    left([field],instr([field],"-")-1) & mid([field],instr([field],"-")+1)

    but this ONLY works if every record has the dash.

  3. #3
    Annnnn is offline Novice
    Windows 10 Access 2007
    Join Date
    Feb 2018
    Posts
    17
    Hi tnx,
    But I really want to "create" data from data found in 2 other fields. So it's not that I want to only display the data because the data does not yet exists.

    I have the following fields that I want to manually enter:
    Sample_Type : Tissue
    Patient_Name : 00-000-000

    From these 2 I want to make 00000000T (or in case the Type is: Reference; ending on R)

    It is really a form for data entry

  4. #4
    Annnnn is offline Novice
    Windows 10 Access 2007
    Join Date
    Feb 2018
    Posts
    17
    Never mind I got it XD XD

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Why save calculated value? It can be calculated when needed.

    Name parts should be saved into individual fields.

    Why does the name value have a hyphen and why do you need to remove it? In some names a hyphen is a valid character.
    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.

  6. #6
    Annnnn is offline Novice
    Windows 10 Access 2007
    Join Date
    Feb 2018
    Posts
    17
    Quote Originally Posted by June7 View Post
    Why save calculated value? It can be calculated when needed.

    Name parts should be saved into individual fields.

    Why does the name value have a hyphen and why do you need to remove it? In some names a hyphen is a valid character.
    I know it is a valid character, but we make a difference between patient namens (with "-" ) and sample names which also indicates what kind
    of material it is. So the 2nd name is based upon the first name.
    May seem strange to u but that's how it has to work because everything I do has to be anonymous...

    It has to be saved because this is a actual value for that perticular sample type received upon a specific date from a specific patient.

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

Similar Threads

  1. Adding where to formula in a query
    By bb_ in forum Access
    Replies: 3
    Last Post: 08-08-2017, 11:03 AM
  2. Adding specific text in table field record
    By nycman in forum Programming
    Replies: 6
    Last Post: 09-07-2015, 05:52 PM
  3. Formula and Text inside a Text box
    By trident in forum Forms
    Replies: 1
    Last Post: 04-18-2015, 02:38 AM
  4. Entering formula in text box
    By GregHolden in forum Reports
    Replies: 3
    Last Post: 02-02-2013, 07:48 PM
  5. Replies: 3
    Last Post: 11-24-2012, 05:35 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