473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Checkbox Required

I have the following code for a form with a checkbox:

If Me!ServiceWork And IsNull(Me!PrimaryBusiness) Then
Cancel = True
MsgBox "If Service Work is checked, Must Choose Primary Business.",
48, "Required Field"
Me!PrimaryBusiness.SetFocus
End If

End Sub

The above requires the user to choose a primay business if service work
box is checked. I want it to work backwards as well and am having some
trouble. If the primary business combobox is a value such as "Repair
Shop" then I want the servicework checkbox to be required. Please
help. Thanks.

Apr 22 '06 #1
4 2451
On 22 Apr 2006 11:05:19 -0700, fo*******@martecgroup.com wrote:

The code depends on how that combobox is set up (1-column, multiple
columns). I would write the code in the PrimaryBusiness_AfterUpdate
event, and automatically select the Service Work checkbox:
if Me.PrimaryBusiness = "Repair Shop" then
Me.ServiceWork = True
end if

-Tom.

I have the following code for a form with a checkbox:

If Me!ServiceWork And IsNull(Me!PrimaryBusiness) Then
Cancel = True
MsgBox "If Service Work is checked, Must Choose Primary Business.",
48, "Required Field"
Me!PrimaryBusiness.SetFocus
End If

End Sub

The above requires the user to choose a primay business if service work
box is checked. I want it to work backwards as well and am having some
trouble. If the primary business combobox is a value such as "Repair
Shop" then I want the servicework checkbox to be required. Please
help. Thanks.


Apr 22 '06 #2
The combo box is 1 column and the user can make only one selection. If
the user selects any type of business that contains service work then I
want the service work checkbox to be required before the user can move
to the next record. I have tried the suggested code in the afterupdate
and it is still allowing the user to go to next record even if
selection from combo box is "repair shop". Thanks.

Apr 22 '06 #3
On 22 Apr 2006 11:32:02 -0700, fo*******@martecgroup.com wrote:

However, my code checks the box if the combobox is set to Repair Shop.
Perhaps the user can uncheck it after that? If so, prevent that with
another line of code:
Me.ServiceWork.Locked = True

Certainly you can also perform an additional check in
Form_BeforeUpdate:
if Me.PrimaryBusiness = "Repair Shop" and Me.ServiceWork = False then
MsgBox "Fit it!"
Cancel=True
end if

Also, I forgot to mention this earlier: ServiceWork should be a Yes/No
field, with a default value (presumably No), and be a required field.
If not required the value can be Null, which most often does not make
much sense.

-Tom.

The combo box is 1 column and the user can make only one selection. If
the user selects any type of business that contains service work then I
want the service work checkbox to be required before the user can move
to the next record. I have tried the suggested code in the afterupdate
and it is still allowing the user to go to next record even if
selection from combo box is "repair shop". Thanks.


Apr 22 '06 #4
are *all* selections in the PrimaryBusiness droplist considered to be
"service work"? if not, then how do you determine which businesses are
service work, and which are not?

hth
<fo*******@martecgroup.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
I have the following code for a form with a checkbox:

If Me!ServiceWork And IsNull(Me!PrimaryBusiness) Then
Cancel = True
MsgBox "If Service Work is checked, Must Choose Primary Business.",
48, "Required Field"
Me!PrimaryBusiness.SetFocus
End If

End Sub

The above requires the user to choose a primay business if service work
box is checked. I want it to work backwards as well and am having some
trouble. If the primary business combobox is a value such as "Repair
Shop" then I want the servicework checkbox to be required. Please
help. Thanks.

Apr 23 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: David Jubinville | last post by:
Hi All, I recently came across an annoying problem and would greatly appreciate any help someone/anyone could offer. Here we go: 1. We have a 'Checklist' consisting of checkboxes and relating...
2
by: Tomas Vera | last post by:
Hello All, I'm having problems creating a page with dynamic checkboxes in a WebApp. In my app, I need to query a database, then (based on results) add checkboxes to my form and set their...
1
by: kiran | last post by:
I cratee a form to meet the fallowing requirement. 1. If any node is selected the corresponding checkbox should be checked 2. If any checkbox is clicked the corresponding node should be selected ...
5
by: Leo J. Hart IV | last post by:
Hello, I'm hoping someone can help me out. I was wondering if the Enabled property of a CheckBox or RadioButton server control is stored in the ViewState. If not, is there some way to to add...
2
by: Asha | last post by:
greetings i want to use the required field validator control to validate a checkbox. here is the code implemented. <asp:RequiredFieldValidator ID="rfv" ControlToValidate="chkDistiAudit"...
2
by: Nu2ASP.NET | last post by:
What I am trying to do is essentially 'flip' the bits, when the user clicks in the checkbox. For example, if the CheckBox appears checked, and the user un-checks it, I want the underlying data...
4
by: SJ | last post by:
Hi all, I have come across a weird problem when attempting to automatically set the focus in a vb.net form to a checkbox control... In my form I have (on a tab page in a tab control) several...
2
by: Javier | last post by:
Hi Everyone, I have a dynamic checkbox in a datagrid that uses the ITemplate interface and has the checkchanged event wired up. When the checkbox is checked, the event event handler that...
37
by: viki1967 | last post by:
Hi all. I have this simple form. I need if checkbox C_1 is selected: 1) field name="n_1" is required and accept only numbers; 2) field name="n_2" is required and accept only numbers; I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.