Results 1 to 12 of 12
  1. #1
    themushroomking is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2016
    Posts
    23

    Show image only when field has a value

    Hi dear people of Accessforums,


    Im Bruce, new here at this forum but also new to Access. I have experience with php and mysql and so on. But inside the company i work for, i am only allowed to use Access and have alot to learn.

    Question:

    I have made some form with a bunch of fields. I want these fields to trigger the status of something.
    So what i would like to have; is an image showing up on the form, whenever someone fills in anything in a specific text-field. If the field is empty, show nothing.

    What i have so far is that; i put an image in > go to "record source" > and in the expression builder i put this:

    IIf(IsNotNull([Field])=True; "ready.png")

    Can someone help me with this? I tried a bunch of different things but i dont get it to work. The image is just there always......
    Thanks in advance!

    Cheers!

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    not clear on what you are trying to achieve, or to be more precise what you have. Suggest provide a bit more detail -

    what is go to "record source" - an image control?

    where are you putting IIf(IsNotNull([Field])=True; "ready.png")?

    and use the actual names you have for controls and field names and what types they are (image, text, combo etc), it could be the problem is with using illegal names or treating them incorrectly.

    With regards this code, there are a number of problems

    1. iif requires a result if true and a result if false - you have only got a result for true
    2. there is no such function as isnotnull in vba, that is a sql expression (which would be 'field is not null' anyway when used there)
    3. in VBA, you use the isnull function
    4. if this is in the controlsource to a control, it needs to be preceded with

    so something like (note I have simplified the test)

    =IIf(IsNull([ControlName]);""; "ready.png")

    I'm also assuming your language requires the use of a semi-colon ; instead of a comma.

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The language s/b English since the op is in UK.

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    since the op is in UK.
    How can you tell that? There is nothing I can see in the OPs profile but I can see you are in US....

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Admin's have additional privileges. Shhh...it's a secret.

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    to quote current UK political mission statement - 'for everyone, not just the privileged few'

  7. #7
    themushroomking is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2016
    Posts
    23
    Hi there Ajax! Thanks for your reply and sorry for my late one :P

    Well, what i have is just a registration form for orders. I want to represent the status of the order (created, in progress, ready for shipment).
    The different fields in the form will trigger the status. So if someone for example fills in the "First name" field, it will show the order is created...
    Later on, when the last field of the shipment details are filled out, i want it to say ready for shipment.

    So theres 3 different status indications
    The fields should trigger an image to appear or whatever.
    So like i said, when someone fills in anything in the "first_name" field, it should trigger the image "order_created.png" to appear on that specific orderID


    So what i have now still is this:

    =IIf(IsNull([first_name])=true "order_created.png")

    And that should happen on only the current record...
    I cant figure it out im so lost. Its pretty much the last thing i need to figure out before putting it to use....
    Thanks in advance!

  8. #8
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    With respect, repeating your original post doesn't help. Please answer my questions

  9. #9
    themushroomking is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2016
    Posts
    23
    I see. Im sorry, not used to forums all that much. Thanks for your patients its a good trait.

    I put my answers in bold/cursive. Thank you!


    what is go to "record source" - an image control?
    I meant the following menu item: Property sheet > Data > Record source

    where are you putting IIf(IsNotNull([Field])=True; "ready.png")?
    I put in an image, then go to record source ..., and type the code in the expression builder

    and use the actual names you have for controls and field names and what types they are (image, text, combo etc), it could be the problem is with using illegal names or treating them incorrectly.
    They are just plain text fields. The name of the field in this case refers to "first_name".

    With regards this code, there are a number of problems

    1. iif requires a result if true and a result if false - you have only got a result for true
    It shouldnt actually be true or false i recon...its just either null or notnull right? What i want is, if they type something in that field, the image shows. So it should be IF FIELD = ISNULL DONT SHOW IMAGE.PNG (hypothetical)

    2. there is no such function as isnotnull in vba, that is a sql expression (which would be 'field is not null' anyway when used there)
    Got it

    3. in VBA, you use the isnull function
    ok

    4. if this is in the controlsource to a control, it needs to be preceded with

    so something like (note I have simplified the test)

    =IIf(IsNull([ControlName]);""; "ready.png")
    I tried this code replacing it with the right names but doesnt seem to work. I typed the code in the expression builder...??
    The image just stays on, period.


    I'm also assuming your language requires the use of a semi-colon ; instead of a comma.
    oops

  10. #10
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    I meant the following menu item: Property sheet > Data > Record source
    record source relates to a form, not a control - and I was asking what type of control? Do you mean the form?

    where are you putting IIf(IsNotNull([Field])=True; "ready.png")?
    I put in an image, then go to record source ..., and type the code in the expression builder
    please clarify - you have a field called field? and the expression builder has come up with a function called IsNotNull? and didn't require you to complete the 'false' part of the statement?

    It shouldnt actually be true or false i recon...its just either null or notnull right?
    wrong - google 'access vba iif' and 'access vba isnotnull'

    I'm also assuming your language requires the use of a semi-colon ; instead of a comma.
    oops
    if you were using the expression builder it would have used commas. This implies you are free typing your code and as a result creating a completely fictitious problem.

    I'm really not prepared to waste my time trying to provide a solution to a piece of fiction.

    provide the code actually used (it's not difficult - just copy and paste)

  11. #11
    themushroomking is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2016
    Posts
    23
    I dont have any code right now that i use because i dont know what to use.
    I think my initial question was TOTALLY reasonable;

    How do i make an image appear, only if someone fills in a specific text field.

    The fact if its fiction or not has nothing to do with this. Ill try another forum. Thanks

  12. #12
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    sorry I can't help, good luck with your porject

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

Similar Threads

  1. Cannot show the link image steadily
    By pencheng in forum Access
    Replies: 4
    Last Post: 07-18-2016, 03:15 AM
  2. Show image in subform , Access 2007
    By s128 in forum Forms
    Replies: 1
    Last Post: 06-03-2013, 06:46 AM
  3. Show/ hide image based on some field value
    By capitala in forum Reports
    Replies: 4
    Last Post: 04-06-2013, 10:56 AM
  4. Combo Box value hide/show Image
    By alyon in forum Access
    Replies: 7
    Last Post: 12-13-2012, 09:48 AM
  5. Show a new image per record in a form
    By Bert Colourama in forum Forms
    Replies: 0
    Last Post: 09-25-2008, 05:22 AM

Tags for this Thread

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