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 |
#1
|
|||
|
|||
Option group criteria
Hi all,
I have a subform with 7 option groups (with check boxes), and a text box for comments at the bottom. I need the txtcomments to be a required field IF any "no" is checked for any of the option groups. If an attempt is made to close the form without adding a comment (and one or more of the check boxes is checked "no"), I want a message to display "Please enter a comment...". Please help! |
#2
|
|||
|
|||
Option group criteria
You would need to check the value of each option group and then if one
is No, display your message. An option group usually assigns a number to each value, say 1 for Yes and 2 for No. Put this in the On Unload property of the form. If Me.OptionGroup1 = 2 OR Me.OptionGroup2 = 2 OR Me.OptionGroup3 = 2 OR Me.OptionGroup4 = 2 OR Me.OptionGroup5 = 2 OR Me.OptionGroup6 = 2 OR Me.OptionGroup2 = 2 Then Msgbox "You need to enter comments", vbOKonly Cancel = True End IF |
#3
|
|||
|
|||
Option group criteria
Jeff L wrote: You would need to check the value of each option group and then if one is No, display your message. An option group usually assigns a number to each value, say 1 for Yes and 2 for No. Put this in the On Unload property of the form. If Me.OptionGroup1 = 2 OR Me.OptionGroup2 = 2 OR Me.OptionGroup3 = 2 OR Me.OptionGroup4 = 2 OR Me.OptionGroup5 = 2 OR Me.OptionGroup6 = 2 OR Me.OptionGroup2 = 2 Then Msgbox "You need to enter comments", vbOKonly Cancel = True End IF |
#4
|
|||
|
|||
Option group criteria
Jeff L wrote: You would need to check the value of each option group and then if one is No, display your message. An option group usually assigns a number to each value, say 1 for Yes and 2 for No. Put this in the On Unload property of the form. If Me.OptionGroup1 = 2 OR Me.OptionGroup2 = 2 OR Me.OptionGroup3 = 2 OR Me.OptionGroup4 = 2 OR Me.OptionGroup5 = 2 OR Me.OptionGroup6 = 2 OR Me.OptionGroup2 = 2 Then Msgbox "You need to enter comments", vbOKonly Cancel = True End IF Maybe I should have mentioned the option groups are in a subform. I entered the above in the On Unload property of the main form, but upon closing the form I got this error: Compile error: method or data member not found "Private Sub Form_Unload(Cancel As Integer)" is highlighted in yellow I'm new at this, I have a huge Access book in front of me, and have been googling like crazy. Thanks for your help! |
#6
|
|||
|
|||
Option group criteria
Jeff L wrote: Yes, having the option groups in a subform definately makes a difference. In that case your syntax would be Forms!MainFormName!SubFormName!OptionGroupName instead of Me.OptionGroupName. Substitute the Names for whatever you have called them. wrote: Jeff L wrote: You would need to check the value of each option group and then if one is No, display your message. An option group usually assigns a number to each value, say 1 for Yes and 2 for No. Put this in the On Unload property of the form. If Me.OptionGroup1 = 2 OR Me.OptionGroup2 = 2 OR Me.OptionGroup3 = 2 OR Me.OptionGroup4 = 2 OR Me.OptionGroup5 = 2 OR Me.OptionGroup6 = 2 OR Me.OptionGroup2 = 2 Then Msgbox "You need to enter comments", vbOKonly Cancel = True End IF Maybe I should have mentioned the option groups are in a subform. I entered the above in the On Unload property of the main form, but upon closing the form I got this error: Compile error: method or data member not found "Private Sub Form_Unload(Cancel As Integer)" is highlighted in yellow I'm new at this, I have a huge Access book in front of me, and have been googling like crazy. Thanks for your help! Okay, I changed the syntax in all cases, and it is still located in the main form's On Unload action. Now, I am not getting an error message, in fact, nothing at all seems to be happening pertaining to this If statement. The msgbox never pops up, and the Comments text box is allowed to remain blank. Sorry for the confusion, please continue to help! This is the exact code: Private Sub Form_Unload(Cancel As Integer) If Forms![All BC]![IEA Review Forms]![Frame130] = 0 Or Forms![All BC]![IEA Review Forms]![Frame144] = 0 Or Forms![All BC]![IEA Review Forms]![Frame151] = 0 Or Forms![All BC]![IEA Review Forms]![Frame158] = 0 Or Forms![All BC]![IEA Review Forms]![Frame165] = 0 Or Forms![All BC]![IEA Review Forms]![Frame172] = 0 Or Forms![All BC]![IEA Review Forms]![Frame179] = 0 Then MsgBox "Please enter comments indicating all problems with this procedure.", vbOKOnly Cancel = True End If End Sub |
#7
|
|||
|
|||
Option group criteria
wrote: Jeff L wrote: Yes, having the option groups in a subform definately makes a difference. In that case your syntax would be Forms!MainFormName!SubFormName!OptionGroupName instead of Me.OptionGroupName. Substitute the Names for whatever you have called them. wrote: Jeff L wrote: You would need to check the value of each option group and then if one is No, display your message. An option group usually assigns a number to each value, say 1 for Yes and 2 for No. Put this in the On Unload property of the form. If Me.OptionGroup1 = 2 OR Me.OptionGroup2 = 2 OR Me.OptionGroup3 = 2 OR Me.OptionGroup4 = 2 OR Me.OptionGroup5 = 2 OR Me.OptionGroup6 = 2 OR Me.OptionGroup2 = 2 Then Msgbox "You need to enter comments", vbOKonly Cancel = True End IF Maybe I should have mentioned the option groups are in a subform. I entered the above in the On Unload property of the main form, but upon closing the form I got this error: Compile error: method or data member not found "Private Sub Form_Unload(Cancel As Integer)" is highlighted in yellow I'm new at this, I have a huge Access book in front of me, and have been googling like crazy. Thanks for your help! Okay, I changed the syntax in all cases, and it is still located in the main form's On Unload action. Now, I am not getting an error message, in fact, nothing at all seems to be happening pertaining to this If statement. The msgbox never pops up, and the Comments text box is allowed to remain blank. Sorry for the confusion, please continue to help! This is the exact code: Private Sub Form_Unload(Cancel As Integer) If Forms![All BC]![IEA Review Forms]![Frame130] = 0 Or Forms![All BC]![IEA Review Forms]![Frame144] = 0 Or Forms![All BC]![IEA Review Forms]![Frame151] = 0 Or Forms![All BC]![IEA Review Forms]![Frame158] = 0 Or Forms![All BC]![IEA Review Forms]![Frame165] = 0 Or Forms![All BC]![IEA Review Forms]![Frame172] = 0 Or Forms![All BC]![IEA Review Forms]![Frame179] = 0 Then MsgBox "Please enter comments indicating all problems with this procedure.", vbOKOnly Cancel = True End If End Sub 0, no; -1, yes |
#8
|
|||
|
|||
Option group criteria
Are you selecting No for an option and are you certain that the No
value is 0 on all your Option Groups? Please check that just to be sure. I have tested what I told you and it does work. I can't see anything wrong with the code itself. |
#9
|
|||
|
|||
Option group criteria
Jeff L wrote: Are you selecting No for an option and are you certain that the No value is 0 on all your Option Groups? Please check that just to be sure. I have tested what I told you and it does work. I can't see anything wrong with the code itself. I am selecting No for an option, and No=0 in all option groups. I'm missing something... |
#10
|
|||
|
|||
Option group criteria
Use basic debugging techniques: before the IF, write a series of MSGBOX
statements to display all the values (one at a time) that you are going to use in the IF. Most likely that will isolate the location of the problem. Edward |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Tab Form navigation | ctdak | Using Forms | 15 | May 31st, 2006 03:05 PM |
using option group to change multiple field query criteria | bicyclops | Running & Setting Up Queries | 1 | December 22nd, 2004 07:43 PM |
Option Group Revisited Again, Help | Henry Smith | Using Forms | 0 | November 2nd, 2004 02:53 AM |
Unbound option group writing text values... | Davie P | Using Forms | 5 | August 12th, 2004 03:49 PM |
Option group selection as query criteria | Tara | Running & Setting Up Queries | 1 | May 28th, 2004 04:18 PM |