A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Option group criteria



 
 
Thread Tools Display Modes
  #1  
Old June 14th, 2006, 07:04 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default 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  
Old June 14th, 2006, 08:24 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default 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  
Old June 14th, 2006, 08:45 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default 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  
Old June 14th, 2006, 08:52 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default 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  
Old June 15th, 2006, 03:41 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default 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  
Old June 15th, 2006, 03:44 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default 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  
Old June 15th, 2006, 04:51 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default 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  
Old June 15th, 2006, 06:20 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default 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  
Old June 16th, 2006, 06:25 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 03:56 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 OfficeFrustration.
The comments are property of their posters.