Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Button Painter 7

Status
Not open for further replies.

cariobulog

Technical User
Oct 30, 2005
44
LY
Anyone could help me how i can make my command button background color changing everytime i click it.
 
may be, because im new in access, ok i check the site of relational.

But for the moment i need only the code of command button which is changing to next color and not going back to the previous color.

for ex. if i click in green then i close the form, again when i want to open the same form it will remain green.

i made a command button which is changing in different color which you show me in this thread but whenever i close it and open it is not saving the color which i save before i close.

If hope i can show you the database which im working but unfortunately i cannot attach here.

thanks
 
OK, I will give sample code after some time.

________________________________________________________
Zameer Abdulla
Help to find Missing people
My father was a realistic father; not a vending machine dispense everything I demanded for!!
 
here is a sample db 12kb zip

It contains only two buttons. You need to repeat the same code for all the buttons.

________________________________________________________
Zameer Abdulla
Help to find Missing people
My father was a realistic father; not a vending machine dispense everything I demanded for!!
 
thank you very much, i tried with my two buttons and now its working.

thanks for being helpful.
 
now i have something else,

Each command button i want to assign a color coding for each click to open a report/form.

many thanks

 
Try adding code below to the click event of the command button. Remember to change "YourFormNameHere" to actual name of the form
Code:
 DoCmd.OpenForm "YourFormNameHere"

________________________________________________________
Zameer Abdulla
Help to find Missing people
My father was a realistic father; not a vending machine dispense everything I demanded for!!
 
thanks, mr. zameer its working!

but it is possible that i can assign a click/color for each form the i want to open?

for ex.

click1 = green = openform1
click2 = blue = openform2
click3 = red = openform3

many thanks.
 
Code not tested
Code:
Private Sub CommandButton1_Click()
    Select Case Me.CommandButton1.BackColor
    Case Is = vbGreen
        DoCmd.OpenForm "Form1"
    Case Is = vbBlue
        DoCmd.OpenForm "Form2"
    Case Is = vbRed
        DoCmd.OpenForm "Form3"
    End Select
End Sub

________________________________________________________
Zameer Abdulla
Help to find Missing people
My father was a realistic father; not a vending machine dispense everything I demanded for!!
 
its working mr. zameer!!, thanks a lot.

there is possibility that i can put anouncement(ex. "you want to open a form? Y/N") because everytime i click the button the form opening automatically. i need to put an "annoucement" that a user can choose if he want to open or not a form




 
code can be shorten but for now
Code:
Private Sub CommandButton1_Click()
  Select Case Me.CommandButton1.BackColor
    Case Is = vbGreen
    If MsgBox("Do you want to open a form?", vbYesNo, "Confirm") = vbYes Then
        DoCmd.OpenForm "Form1"
     End If
    Case Is = vbBlue
    If MsgBox("Do you want to open a form?", vbYesNo, "Confirm") = vbYes Then
        DoCmd.OpenForm "Form3"
     End If
    Case Is = vbRed
    If MsgBox("Do you want to open a form?", vbYesNo, "Confirm") = vbYes Then
        DoCmd.OpenForm "Form2"
     End If
    End Select
End Sub

________________________________________________________
Zameer Abdulla
Help to find Missing people
My father was a realistic father; not a vending machine dispense everything I demanded for!!
 
Now my database is almost done but i have a problem in my main form;

I have a main form with a combox and a subform, in the subform i have a colored command button, which is changing the color everytime i click.
my problem is everytime i print the main form the colored command button in the subform is not appearing, in screen view the color is visible, why in a print preview it doesn't appear?

thanks
 
Make sure that the buttons "Visible Display When" Proeprty is set to "Always"

________________________________________________________
Zameer Abdulla
Help to find Missing people
My father was a realistic father; not a vending machine dispense everything I demanded for!!
 
a star for patience, and an entertaining read.
 
Wow.. that is wonderful.. thanks for the star.

________________________________________________________
Zameer Abdulla
Help to find Missing people
My father was a realistic father; not a vending machine dispense everything I demanded for!!
 
The "Display When" Proeprty is set already to "Always", but still the color is not appearing?

thanks
 
I read your post again..
It is the when the form is a subform then it is not showing the color.
Need more investigation on this..

________________________________________________________
Zameer Abdulla
Help to find Missing people
My father was a realistic father; not a vending machine dispense everything I demanded for!!
 
thanks mr zameer, i dont understand why is colored button is not appearing.

when i select a particular form which has a colored button into combo box and automatically displayed in the subform and if i try to print preview the main form, the colored button in the subform is not displaying.

try this with the file which you sent to me.

create a main form then put the form which you made into a subform, then try to print preview the main form.

you will see the color button is not displaying.

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top