Changing toggle button caption in sub form dependent on underlying value

M

Michael

I have a main form with a subform that is continuous and displays records
selected by a query using a key from the main form. It works fine.

One of the fields in the subform is a Yes/No field with a toggle button to
set it. As such it works fine.

I wanted to alter the caption on the button depending on whether it is
depressed or not. I have tried various methods but all seem to result in ALL
of the toggle buttons in the subform changing their captions rather then the
one on the specific row.

I have tried adding a field (txttogCaption) to the query which is set with
an IIF in the query depending on the value of the Yes/No field - just
running the query it populates the query field correctly depending on the
row value.

However, when applying it to the form in the OnCurrent event as follows it
sets all row button captions to the value of the first one.

Forms!F_frmPhotoListDisplay!F_frmPhotoListDisplaysubform2!togPersonPicturedOrAssociatedWith.Caption
= _
Forms!F_frmPhotoListDisplay!F_frmPhotoListDisplaysubform2!txttogCaption

I have also tried putting IIF(True,"Pic","Ass") into the Caption property of
the toggle control.

How can I get it to only update the caption on the button on the specific
row that is changed?

Help would be appreciated.

Michael.
 
N

NevilleT

Hi Michael

Don't think you will do it that way. Try using conditional formatting. You
can either use the built in function or VBA to set the conditions.
 
M

Michael

Hi Neville,

Conditional formatting is greyed out on the menu - I have selected the
toggle button control and ensured it has focus in form edit.

Might I be missing something here?

Michael.
 
N

NevilleT

Hi Michael

You are right. I was actually thinking reports where you can use the
OnDetail. Here is another solution. In your query, add a new column
txtButtonCaption: iif(YesNoField=true,"True","False")

Add the field to the form and place it over the button so that it completely
covers the button. Use the OnClick for the textbox to change the value. The
button is there purely for cosmetic purposes. You will need to do a requery
after the value changes, and may need to bookmark the record. Should work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top