If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
|
Thread Tools | Display Modes |
#11
|
|||
|
|||
Radio Button Problem
Thats it.....working perfectly now !. Thank you for taking the time to help
me Daryl i certainly appreciate it. Bruce, cheers for the advice regarding the newsreader, i'll definitely look into it. Also, please relay my thanks to anyone who took the time to answer but whose post didn't appear in the thread. You guys are great. Jen xoxo "BruceM" wrote: Jen, There have been a number of replies in this thread that are not showing up here. I used AccessMonster, and Al Campagna made some replies too. If you are using the Microsoft web interface you are not getting all of the conversation. The web interface has often had problems, and it seems unlikely it will ever be reliable. Maybe the problem is somewhere other than the Microsoft web page, but I doubt it. You should use a different news reader. For web interfaces AccessMonster is not too bad, but best would be a newsreader. Most e-mail programs can be used as newsreaders, or you can use a dedicated newsreader program. In any case, the Click event will fire when you click anywhere within the option group that is not already occupied by another control. The best event to use is After Update. Also, the Load event will apply only to the first record you see upon loading the form. The formatting applied then will remain until the next time you update the option group (or click it, if you decide to go that way). It will not change when you move to another record. To do that you need to use the form's Current event. You can call the option group After Update event in the form's Current event or vice versa, but since either event could have code beyond what applies to formatting, you may do better to create your own function. In the VBA editor click Insert Procedure. Choose Function and Private, and give it a name such as ControlColor. You can make the function Public, but if it is to be used only for the one form there is no need to do that. Insert the formatting code between Private Function ControlColor() and End Function. In the form's Current event or the option group After Update event: Call ControlColor Here is the reply I posted last week: *********** This is where an Option Group comes into play. Create an option group using the toolbox. Add option buttons inside the option group box. You may need to create new ones, as I think option buttons created outside an option group have different properties than ones created inside the option group. Assign each button an Option Value. Use 1 and 2. It doesn't matter which is which, but for this discussion active is 1 and Inactive is 2. Bind the option group to a number field ActiveStatus. You can set the default value of the option group to 0, which should leave you with white buttons rather than gray until one of the choices is selected. Or set the Default Value to 1 to mark the Active button by default for a new record. You no longer have an Active field and an Inactive field, but a single ActiveStatus field that will be 1 for Active and 0 for Inactive. Remember, the Option Group is bound to the field. The buttons are not bound to any field. I will call the Option Group grpActive, and the Labels lblActive and lblInactive. In the After Update event of grpActive: If Me.grpActive = 1 Then Me.lblActive.BackColor = vbGreen Me.lblInactive.BackColor = vbWhite ElseIf Me.grpActive = 2 Then Me.lblActive.BackColor = vbWhite Me.lblInactive.BackColor = vbRed Else Me.lblActive.BackColor = vbGreen Me.lblInactive.BackColor = vbWhite End If You could also use Select Case Select Case Me.grpActive Case 1 Me.lblActive.BackColor = vbGreen Me.lblInactive.BackColor = vbWhite Case 2 Me.lblActive.BackColor = vbWhite Me.lblInactive.BackColor = vbRed Case Else Me.lblActive.BackColor = vbWhite Me.lblInactive.BackColor = vbWhite End If You can simplify the expression if there are just two options: If Me.grpActive = 1 Then Me.lblActive.BackColor = vbGreen Me.lblInactive.BackColor = vbWhite Else Me.lblActive.BackColor = vbWhite Me.lblInactive.BackColor = vbRed End If You will need the same code in the form's Current event so the labels display correctly when you arrive at an existing record. ***************** Al suggested that for Active or Inactive there are just two choices, so a single check box may be preferable to an Option Group. It would certainly be simpler. You can see the full discusssion at www.accessmonster.com "Jen" wrote: Hi Daryl, Thanks for your help....i've put the code in the Click event of the option group but i'm not sure what you mean by 'call from the Load or Current form events'. Does this mean i also must put the same code in the Load event of the form itself ? I'm no expert so sorry if this is a silly question Thanks, Jen "Daryl S" wrote: Jen - Put this code in the option group Click event (change all occurrences of opActiveInactive below to the name of your option group, and if necessary, change the values of the active and inactive options). Private Sub opActiveInactive_Click() ' If Active is chosen, turn that label green. If Inactive, turn that lavel red If Me.opActiveInactive.Value = 1 Then Me.lblActive.ForeColor = vbGreen Me.lblInactive.ForeColor = vbBlack Else Me.lblActive.ForeColor = vbBlack Me.lblInactive.ForeColor = vbRed End If End Sub You will also need to call this from the Load or Current form events so it is set initially. As for one radio button always selected, set the default to either Active or Inactive, and that will take care of it. -- Daryl S "Jen" wrote: Hi again guys, I've got a form which, among other controls, has two radio buttons beside each other with the labels 'Active' and 'Inactive'. This relates to whether a member of staff is currently working on a particular job or not. My problem is that when i click in the 'Active' control, i'd like the label to turn green and when i click in the 'Inactive' control, i'd like that label to turn red and the other label to revert back to plain white. I'd also only like one 'dot' to be visible at all times. Is this possible ?? Hope i've explained it ok Thanks guys, Jen |
#12
|
|||
|
|||
Radio Button Problem
Bruce,
There have been a number of replies in this thread that are not showing up here. Good point! I didn't know about that issue... Thanks, Al Campagna "BruceM" wrote in message ... Jen, There have been a number of replies in this thread that are not showing up here. I used AccessMonster, and Al Campagna made some replies too. If you are using the Microsoft web interface you are not getting all of the conversation. The web interface has often had problems, and it seems unlikely it will ever be reliable. Maybe the problem is somewhere other than the Microsoft web page, but I doubt it. You should use a different news reader. For web interfaces AccessMonster is not too bad, but best would be a newsreader. Most e-mail programs can be used as newsreaders, or you can use a dedicated newsreader program. In any case, the Click event will fire when you click anywhere within the option group that is not already occupied by another control. The best event to use is After Update. Also, the Load event will apply only to the first record you see upon loading the form. The formatting applied then will remain until the next time you update the option group (or click it, if you decide to go that way). It will not change when you move to another record. To do that you need to use the form's Current event. You can call the option group After Update event in the form's Current event or vice versa, but since either event could have code beyond what applies to formatting, you may do better to create your own function. In the VBA editor click Insert Procedure. Choose Function and Private, and give it a name such as ControlColor. You can make the function Public, but if it is to be used only for the one form there is no need to do that. Insert the formatting code between Private Function ControlColor() and End Function. In the form's Current event or the option group After Update event: Call ControlColor Here is the reply I posted last week: *********** This is where an Option Group comes into play. Create an option group using the toolbox. Add option buttons inside the option group box. You may need to create new ones, as I think option buttons created outside an option group have different properties than ones created inside the option group. Assign each button an Option Value. Use 1 and 2. It doesn't matter which is which, but for this discussion active is 1 and Inactive is 2. Bind the option group to a number field ActiveStatus. You can set the default value of the option group to 0, which should leave you with white buttons rather than gray until one of the choices is selected. Or set the Default Value to 1 to mark the Active button by default for a new record. You no longer have an Active field and an Inactive field, but a single ActiveStatus field that will be 1 for Active and 0 for Inactive. Remember, the Option Group is bound to the field. The buttons are not bound to any field. I will call the Option Group grpActive, and the Labels lblActive and lblInactive. In the After Update event of grpActive: If Me.grpActive = 1 Then Me.lblActive.BackColor = vbGreen Me.lblInactive.BackColor = vbWhite ElseIf Me.grpActive = 2 Then Me.lblActive.BackColor = vbWhite Me.lblInactive.BackColor = vbRed Else Me.lblActive.BackColor = vbGreen Me.lblInactive.BackColor = vbWhite End If You could also use Select Case Select Case Me.grpActive Case 1 Me.lblActive.BackColor = vbGreen Me.lblInactive.BackColor = vbWhite Case 2 Me.lblActive.BackColor = vbWhite Me.lblInactive.BackColor = vbRed Case Else Me.lblActive.BackColor = vbWhite Me.lblInactive.BackColor = vbWhite End If You can simplify the expression if there are just two options: If Me.grpActive = 1 Then Me.lblActive.BackColor = vbGreen Me.lblInactive.BackColor = vbWhite Else Me.lblActive.BackColor = vbWhite Me.lblInactive.BackColor = vbRed End If You will need the same code in the form's Current event so the labels display correctly when you arrive at an existing record. ***************** Al suggested that for Active or Inactive there are just two choices, so a single check box may be preferable to an Option Group. It would certainly be simpler. You can see the full discusssion at www.accessmonster.com "Jen" wrote: Hi Daryl, Thanks for your help....i've put the code in the Click event of the option group but i'm not sure what you mean by 'call from the Load or Current form events'. Does this mean i also must put the same code in the Load event of the form itself ? I'm no expert so sorry if this is a silly question Thanks, Jen "Daryl S" wrote: Jen - Put this code in the option group Click event (change all occurrences of opActiveInactive below to the name of your option group, and if necessary, change the values of the active and inactive options). Private Sub opActiveInactive_Click() ' If Active is chosen, turn that label green. If Inactive, turn that lavel red If Me.opActiveInactive.Value = 1 Then Me.lblActive.ForeColor = vbGreen Me.lblInactive.ForeColor = vbBlack Else Me.lblActive.ForeColor = vbBlack Me.lblInactive.ForeColor = vbRed End If End Sub You will also need to call this from the Load or Current form events so it is set initially. As for one radio button always selected, set the default to either Active or Inactive, and that will take care of it. -- Daryl S "Jen" wrote: Hi again guys, I've got a form which, among other controls, has two radio buttons beside each other with the labels 'Active' and 'Inactive'. This relates to whether a member of staff is currently working on a particular job or not. My problem is that when i click in the 'Active' control, i'd like the label to turn green and when i click in the 'Inactive' control, i'd like that label to turn red and the other label to revert back to plain white. I'd also only like one 'dot' to be visible at all times. Is this possible ?? Hope i've explained it ok Thanks guys, Jen |
|
Thread Tools | |
Display Modes | |
|
|