I need help with conditional Icons/Pictures (1 Viewer)

lbenjaminl

New member
Local time
Today, 15:21
Joined
Sep 28, 2022
Messages
8
I have a Access 2016 DB. I am working on a Form that has a master/child relationship. This works perfectly. The subform works perfectly and loads the filtered rows as designed. The problem that I am tring to solve is that I have 9 Yes/No (-1/0) ControlSource fields. I am trying to relate each of those fields to a icon. When the value is True, I want the imgGreenCheck to display. When the value is False, I want the imgOrangeCheck to display. I have hidden both the Green and Orange check images on the row (invisible) and have seeded the Columns for the 9 Control Sources with their ownGreen images.

I can't seem to get the images to update. I have tried; updating the fields in the OnLoad event, OnCurrent event. I have placed individual txtboxes on the row for each of the control source fields that perform the controlsource calculation (=IIf([MenuDetailPotassium]=-1,[imgPotassium].[Picture]=[imgGreen.[Picture],[imgPotassium].[Picture] = [imgOrange].[Picture]))

I don't know what else to try.

Lynda
 

lbenjaminl

New member
Local time
Today, 15:21
Joined
Sep 28, 2022
Messages
8
I might as well add: I also want to modify a table field to become a weblink if another column (defined as a link) is populated. Any clue? I dont want to have a naked web address.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 21:21
Joined
Feb 19, 2013
Messages
16,653
your form has a query using multiple tables which makes it not updateable. General rule is one form, one table, sometimes you can get away with 2 and sometimes you can change the recordset type to dynaset - inconsistent updates. But not in this case.

Modify your form design to have another subform. Put the description etc in the mainform part and the tickboxes in the new subform
 

bob fitz

AWF VIP
Local time
Today, 21:21
Joined
May 23, 2011
Messages
4,726
Something like:
If [MenuDetailPhosphorous] = -1 Then
[imgPhosphorous].[Visible] = -1
Else
[imgPhosphorous].[Visible] = 0
End If
for each control, in the Current event of the form should work.
 

bob fitz

AWF VIP
Local time
Today, 21:21
Joined
May 23, 2011
Messages
4,726
Forgot to mention that you'll also have to remove: imgPhosphorous from the control source of the control called: imgPhosphorous
 

lbenjaminl

New member
Local time
Today, 15:21
Joined
Sep 28, 2022
Messages
8
your form has a query using multiple tables which makes it not updateable. General rule is one form, one table, sometimes you can get away with 2 and sometimes you can change the recordset type to dynaset - inconsistent updates. But not in this case.

Modify your form design to have another subform. Put the description etc in the mainform part and the tickboxes in the new subform
Both the master form AND the subform are read only. They are not update-able. The tick boxes are a part of the recordset of the subform recordset, as they are normalized attributes of the table.
 

lbenjaminl

New member
Local time
Today, 15:21
Joined
Sep 28, 2022
Messages
8
I guess I can cheat and make the subform update-able. And then set all the fields to not enabled and not Tab stops. I will try that.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 21:21
Joined
Feb 19, 2013
Messages
16,653
as they are normalized attributes of the table.
Well, actually, they are not - because if you ever had to add another one (or remove one) you would need to modify your tables, queries, forms and reports. If it was properly normalised, you would just add one record

But if you don't need the user to change the values, you can leave it as unupdateable

to just display the icons as required you would need code to loop through each field. something like this in the form load event

Code:
dim fld as dao.field

for each fld in recordset.fields
    if fld.type=1 then 'is a boolean
        me("img" & replace(fld.name,"MenuDetail","")).picture="GreenCheck32"
    else
         me("img" & replace(fld.name,"MenuDetail","")).picture="OrangeCheck32"
    end if

next ctl
 

Knives

New member
Local time
Tomorrow, 04:21
Joined
Feb 19, 2020
Messages
6
I have a Access 2016 DB. I am working on a Form that has a master/child relationship. This works perfectly. The subform works perfectly and loads the filtered rows as designed. The problem that I am tring to solve is that I have 9 Yes/No (-1/0) ControlSource fields. I am trying to relate each of those fields to a icon. When the value is True, I want the imgGreenCheck to display. When the value is False, I want the imgOrangeCheck to display. I have hidden both the Green and Orange check images on the row (invisible) and have seeded the Columns for the 9 Control Sources with their ownGreen images.

I can't seem to get the images to update. I have tried; updating the fields in the OnLoad event, OnCurrent event. I have placed individual txtboxes on the row for each of the control source fields that perform the controlsource calculation (=IIf([MenuDetailPotassium]=-1,[imgPotassium].[Picture]=[imgGreen.[Picture],[imgPotassium].[Picture] = [imgOrange].[Picture]))

I don't know what else to try.

Lynda
You want it to automatically change depending on the checkboxes, something like this?

I feel bored and so I modified the database file, feel free to use it...

1676472547688.png
 

Attachments

  • MyDatabase.accdb
    2.9 MB · Views: 63

Users who are viewing this thread

Top Bottom