MS Access - conditional format a command button

Ross
Ross used Ask the Experts™
on
I have a continuous form that has a command button on it that opens another form (based on a query on another table) where the PK of the first form and second form match, so the second form only shows data relating to the record we're on in the continuous form.

What I want to achieve is for the command button to be a different colour to normal if there is any records found for the second form - IE, if there's no linked data from the query, leave the button normal, if there's any records found in the query (that would be shown in the form) then the button should be a different colour.

I hope I've explained myself clearly enough!

Thanks!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You might not get what you want for a continuous form. You may have only one button and displayed as many times as the records you have in a form. The properties of that button are carried out to the replicated buttons.

So, if you implement a code to change any property e.g. forecolor of the button, the same property is applied to all.


Ed

Author

Commented:
can i not change the way i'm doing it a little by using onfocus for the current record to set the button colour when the record is entered? IE default all buttons to "normal" when that record is entered it's button changes?

Thanks!
I don't think so.

I say that because if you call that button in a code, you are referring to the same button.

Ed
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
even with Me!Button?
Yes, that is what I know.

Ed
My best approach on this kind of scenario is to use a conditional formatting on any of the fields and not the command button.

I may suggest to use the DlookUp function for this purpose like the one below:

1. Under the condition, use the Expression Is
2. DLookUp("ID","tblYourTable","ID=" & Nz([Forms]![frmName]![ID],0) & "")

Sincerely,
Ed

Author

Commented:
thats a good solution - didn't think of that. Just means it's not "perfect" but I can educate the users that the effect is the same thing :) Ideal!

Cheers.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial