Command Button

tjones

Registered User.
Local time
Today, 09:48
Joined
Jan 17, 2012
Messages
199
Form Background: I have a Single Form (necessary due to a Cascading Combo Box series) with a subForm datasheet. I enter the information into the Single Form (CourseTaken) and use a query to pull all related information into the DataSheet (CourseSummary) thereby mocking a split form. the two forms are tied using StudentID and CourseTakenID. The form has several command buttons. The Practicum/Portfolio/Paper buttons open forms that hold all other information required that is not on the CourseTaken form.

What I want to be able to do is this: When a student begins their P/P/P course the status is changed to "In Progress" ect. Using the information entered in the CourseTaken form "CourseNoID" and "CourseStatus" to change the color of the P/P/P button (located on the CourseTaken form). with the color change visible whenever the CourseTaken form is open not matter which record is loaded into the form itself.

I have tried this code in the On Load and On Current and it works, but ONLY when I select the P/P/P course from the subform and load the record into the fields of the CourseTaken form.

'change button capstone button color for Completed
Dim lngGreen As Long, lngBlue As Long

lngBlue = RGB(64, 224, 208)
lngGreen = RGB(127, 255, 212)

If Me.CourseNoID = "10" And Me.CourseStatus = "Completed" Then
Me.cmdPracticum.BackColor = RGB(64, 224, 208)
End If

The other status' would have different colors.
I have attached a screen grab that may make some sense of what I would like to do CmdBtn Color Change.jpg

I did have another post regarding this back in June 12 but the same happened, only showed when loaded:
http://www.access-programmers.co.uk/forums/showthread.php?t=228865&highlight=cmdbutton
 
Last edited:
Sounds like you need to invstigate using conditional formatting
 
CJ_London I looked at conditional formatting, the problem is that it does not work with a command button, the option becomes unavailable when you select a button. :banghead:
 
A CommandButton can be simulated with a Textbox.

Use the Raised SpecialEffect to make it look like a button. I also make the button depress OnClick by switching from Raised to Sunken and back after a short delay.

BTW The Enabled Property of the textbox can be set using ConditionalFormatting. This is very useful in ContinuousForms where a "button" needs to be conditionally enabled.
 
I'm beginning to think most of the problem is the way the form is set up. A Single Form with a query run Subform.

If I load the Practicum into the form the button reacts the way I want. The problem seems to be coming from the fact that the 3 records (P/P/P) are not loaded and I can not base it off the subform because it is basically view only as it is based on a query.

I made a query that has only the fields I require the fields I need (2 for filtering records in the table to a particular student and 2 with the information I want to base the change on).

I just can't figure out how to base a button event on a query and keep re-querying while the window is open/upon on any change.
 
So I have figured out that I can use "docmd.openquery "qryButtonColor" to return all of an individuals results, but ....

1. How then would I code "look to see if these conditions (C# = 10, S = IP) are true in the query and
if yes, then change button color
if no, do nothing

2. Run the query and code anytime a change is made on the form
 

Users who are viewing this thread

Back
Top Bottom