Results 1 to 11 of 11
  1. #1
    tri.stand is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2019
    Posts
    6

    Custom Text based on field value

    Morning all,



    I'm not very good with Access and certainly have no idea about VBA.
    I am just messing about with importing data from Excel to Access and then displaying it in a Report. So far, I've muddled my way through and learnt a few bits.

    My next target is to have a field/textbox within my Report display a text output based on the look up value in my table.

    I'm trying to lookup TINSPASS which displays one of the following values: -1, 0, 1
    And I would like to to display the following text against each value in my report: -1 = "PASS", 0 = "" (Empty Textbox), 1 = "FAIL"

    Any help would be gratefully received.


    PS: Using Office 365

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Use a combo box with a value list rowsource of

    -1;”pass”;1;”fail”
    Set column count to 2
    Set column width to 0
    Set controlsource to [tinspass]

  3. #3
    tri.stand is offline Novice
    Windows 10 Office 365
    Join Date
    Dec 2019
    Posts
    6
    Thanks @Ajax, I've tried this, but I think i'm missing something as it is displaying the samething (-1, 0, 1)

    I've attached the file
    Attached Files Attached Files

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    away from my computer - but sounds like you have not done this part

    Set column width to 0

    columnwidth is not the same as width (which refers to the control, not the column)

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,938
    Look at how it is done.
    Attached Thumbnails Attached Thumbnails rptCombo.PNG   rptcombo1.PNG  
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    tri.stand is offline Novice
    Windows 10 Office 365
    Join Date
    Dec 2019
    Posts
    6
    Thank You Ajax & Welshgasman!!

    All starting to make sense now. I had "Row Source Type" still set as "Table/Query", changed to "Value List" and problem solved.

    Thank you so much!!!

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    display a text output based on the look up value in my table
    If that means the table field is a lookup field, then while you'll see "Smith" the actual value is a number that's in a hidden table. Might have been the real issue? Might continue to be an issue as well.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    Quote Originally Posted by tri.stand View Post
    I would like to to display the following text against each value in my report: -1 = "PASS", 0 = "" (Empty Textbox), 1 = "FAIL"
    Just set the TINSPASS's Format property to: "Fail";"Pass";""

    Click image for larger version. 

Name:	FormatTextbox.JPG 
Views:	9 
Size:	17.6 KB 
ID:	48064
    Last edited by accesstos; 06-18-2022 at 09:44 AM. Reason: Picture changed

  9. #9
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    Hi
    You will need to change the design of your database.

    You currently have 1 table which is dealing with PQT Testing of various appliances.

    You will need to look at normalising your table.

    A Customer has a property that needs Testing on an Annual basis.

    This means you need multiple tables and not just 1
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  10. #10
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,938
    Very nice
    Quote Originally Posted by accesstos View Post
    Just set the TINSPASS's Format property to: "Fail";"Pass";""

    Click image for larger version. 

Name:	FormatTextbox.JPG 
Views:	9 
Size:	17.6 KB 
ID:	48064
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  11. #11
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Forgotten about the format method.

    to add a bit of colour [Red]"Fail";[Green]"Pass";""

    Only issue would be if user wants to change the value - the underlying value will show so it can be edited. Tho' this being a report, should not be happening

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

Similar Threads

  1. Text field custom formatting
    By PaulMoor in forum Access
    Replies: 3
    Last Post: 05-22-2020, 08:22 AM
  2. Replies: 6
    Last Post: 02-26-2020, 10:03 PM
  3. Replies: 5
    Last Post: 10-03-2014, 11:19 AM
  4. Replies: 2
    Last Post: 05-31-2013, 01:29 PM
  5. Replies: 2
    Last Post: 05-05-2010, 02:52 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