PC Review


Reply
Thread Tools Rate Thread

Require selection from combo on checkbox?

 
 
Steve B
Guest
Posts: n/a
 
      28th Feb 2008
Hi - is it possible to set a form to require a selection from a combo if a
check box is set to true?

I've tried using the validation rule set to the check box name, but it
doesn't work...

 
Reply With Quote
 
 
 
 
Jeff Boyce
Guest
Posts: n/a
 
      28th Feb 2008
Steve

Since we're not there, we don't have any way to know HOW you "tried using
the validation rule ..."

If this were mine, I'd add a validation check in the form's BeforeUpdate
event that ensured that there was a selection made in the combobox if the
checkbox were true (and "Cancel"ed the update if there wasn't).

By the way, you can make it easier for your users to understand that they
need to do something with the combobox if you will add something like the
following to the AfterUpdate event of the checkbox:

Me!YourComboboxName.Enabled = (Me!YourCheckbox = True)

This will enable/disable the combobox, depending on the status of the
checkbox.

You could even use:
Me!YourComboboxName.SetFocus
if the checkbox were true, to remind the user that they need to make a
selection.

Good Luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP

"Steve B" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi - is it possible to set a form to require a selection from a combo if a
> check box is set to true?
>
> I've tried using the validation rule set to the check box name, but it
> doesn't work...



 
Reply With Quote
 
 
 
 
Steve B
Guest
Posts: n/a
 
      28th Feb 2008
Hi Jeff,

Appolgies for the lack of info, I should no better as a whine to staff for
lack of detail!

I've added what I want for the time being by hiding the combo box by using
the following in the form On current event

Private Sub Form_Current()
Me!part1.Visible = Me!Parts_requested
End Sub

and then on the check box After update event

Private Sub Parts_requested_AfterUpdate()
Me!part1.Visible = Me!Parts_requested
End Sub

But will also investigate your helpful suggestions

Thank you for your time

Steve



"Jeff Boyce" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Steve
>
> Since we're not there, we don't have any way to know HOW you "tried using
> the validation rule ..."
>
> If this were mine, I'd add a validation check in the form's BeforeUpdate
> event that ensured that there was a selection made in the combobox if the
> checkbox were true (and "Cancel"ed the update if there wasn't).
>
> By the way, you can make it easier for your users to understand that they
> need to do something with the combobox if you will add something like the
> following to the AfterUpdate event of the checkbox:
>
> Me!YourComboboxName.Enabled = (Me!YourCheckbox = True)
>
> This will enable/disable the combobox, depending on the status of the
> checkbox.
>
> You could even use:
> Me!YourComboboxName.SetFocus
> if the checkbox were true, to remind the user that they need to make a
> selection.
>
> Good Luck!
>
> Regards
>
> Jeff Boyce
> Microsoft Office/Access MVP
>
> "Steve B" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Hi - is it possible to set a form to require a selection from a combo if
>> a check box is set to true?
>>
>> I've tried using the validation rule set to the check box name, but it
>> doesn't work...

>
>


 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      28th Feb 2008
On Thu, 28 Feb 2008 19:48:47 -0000, "Steve B" <(E-Mail Removed)> wrote:

>Hi - is it possible to set a form to require a selection from a combo if a
>check box is set to true?
>
>I've tried using the validation rule set to the check box name, but it
>doesn't work...


Are you using a Form (good) or a table (much less good)? You can do the check
in a Form's BeforeUpdate event:

Private Sub Form_BeforeUpdate(Cancel as Integer)
If Me!checkboxname = True Then
If IsNull(Me!comboboxname) Then
Msgbox "If the checkbox is checked you must select an item", vbOKOnly
Cancel = True
Me!comboboxname.SetFocus
End If
End If
End Sub

If you're using a table... well, don't; but if you are, you'll need to use the
Table Validation rule, not field validation (which cannot refer to other
fields). E.g.

([checkboxname] = True AND [combobox] IS NOT NULL) OR ([checkboxname] = False)
--
John W. Vinson [MVP]
 
Reply With Quote
 
Steve B
Guest
Posts: n/a
 
      29th Feb 2008
Cheers John & Jeff,

Used both your solutions and everything is now perfect!

Steve

"John W. Vinson" <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in message
news(E-Mail Removed)...
> On Thu, 28 Feb 2008 19:48:47 -0000, "Steve B" <(E-Mail Removed)>
> wrote:
>
>>Hi - is it possible to set a form to require a selection from a combo if a
>>check box is set to true?
>>
>>I've tried using the validation rule set to the check box name, but it
>>doesn't work...

>
> Are you using a Form (good) or a table (much less good)? You can do the
> check
> in a Form's BeforeUpdate event:
>
> Private Sub Form_BeforeUpdate(Cancel as Integer)
> If Me!checkboxname = True Then
> If IsNull(Me!comboboxname) Then
> Msgbox "If the checkbox is checked you must select an item", vbOKOnly
> Cancel = True
> Me!comboboxname.SetFocus
> End If
> End If
> End Sub
>
> If you're using a table... well, don't; but if you are, you'll need to use
> the
> Table Validation rule, not field validation (which cannot refer to other
> fields). E.g.
>
> ([checkboxname] = True AND [combobox] IS NOT NULL) OR ([checkboxname] =
> False)
> --
> John W. Vinson [MVP]


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy Selection - Paste Selection - Delete Selection Uninvisible Microsoft Excel Programming 2 25th Oct 2007 01:31 PM
Copy Selection - Transpose Selection - Delete Selection Uninvisible Microsoft Excel Misc 2 23rd Oct 2007 04:18 PM
Material Require. Planning (MRP) & Capacity Require. Planning (CRP =?Utf-8?B?VHJpY2lhIFlvdW5n?= Microsoft Excel Programming 1 1st Feb 2007 07:45 AM
Emails that require follow-up often require a task. =?Utf-8?B?RGFuNjBoZXI=?= Microsoft Outlook Discussion 1 27th Jun 2006 02:23 PM
Require Selection of Combo Box item =?Utf-8?B?S2lyayBQLg==?= Microsoft Access Form Coding 0 19th Jul 2005 04:05 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:22 PM.