tags:

views:

12

answers:

1

hello there i have 5 buttons in row (btn1,btn2,btn3,btn4,btn5) and 1 OK button when i click indivisually to each button of 5 buttons its color changes to red and after click on OK button the color of buttons which are red turns green
the problem is that i don't know how to insert induvisual record of each button of which color is green in access database help me if you have any answer

A: 

I don't like code that reads the colour to decide what action to take so I'd suggest that at the forms loading you set the Tag property of all 5 buttons to false and whenever you change the colour of a button you do for example: btn1.Tag = Not CBool(btn1.Tag).

Then you just have a table in your Access database which have 5 columns, all of type Boolean (can't remember the Access name for that, the type that can store Yes/No) and then store CBool(btn1.Tag) in column1 etc.

ho1
Using the Tag property is almost as bad!
Dan Puzey
Why? It's not great in that it's an object rather than a specific type, but as long as it's done properly I never have any problems with it. The only times it gets messy is if you use it for different things in different parts of the code and you end up not being sure what it value contains.Though I admit that subclassing the control to add your own properties might be better in many cases.
ho1