473,503 Members | 11,435 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Turn off required property via code

27 New Member
I am trying to write an if/then statement to disable the "Required Property" and then to enable it after a record is saved. Almost like the visible and locked code.
Oct 1 '07 #1
8 2589
Scott Price
1,384 Recognized Expert Top Contributor
You have posted your question in the Access Articles section rather than the Access Forum section.
I have moved it across for you.

MODERATOR.
Oct 1 '07 #2
Scott Price
1,384 Recognized Expert Top Contributor
I am trying to write an if/then statement to disable the "Required Property" and then to enable it after a record is saved. Almost like the visible and locked code.
Wouldn't such a code negate the need to have the Required Property set at all?

In other words, why?

Regards,
Scott
Oct 1 '07 #3
Randoz
27 New Member
I have field that is required uless another field is filled in with certan text.
Oct 1 '07 #4
Scott Price
1,384 Recognized Expert Top Contributor
Well, I suppose you know that really doesn't answer the question :-)

You'll need to investigate the DAO Required property. Typing Required into your VBA editor window then pressing F1 will bring up context sensitive help on the keyword.

Good luck!

Regards,
Scott
Oct 1 '07 #5
missinglinq
3,532 Recognized Expert Specialist
Instead of having your field Required and then trying to change this, you need to strip the Required attribute, and use a validation routine to assure that the second field is filled in if the first doesn't have the required data. Something like this, where FieldB is the field that has to contain data if FieldA doesn't hold a certain value.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2.  If Me.FieldA <> "This is the required text" And IsNull(Me.FieldB) Then
  3.   MsgBox "FieldB is Required!"
  4.   Cancel = True
  5.   FieldB.SetFocus
  6. End If
  7. End Sub
Linq ;0)>
Oct 1 '07 #6
Randoz
27 New Member
Thanks Linq, that will do what I need to do.
Oct 2 '07 #7
missinglinq
3,532 Recognized Expert Specialist
Glad we could help!

Linq ;0)>
Oct 2 '07 #8
NeoPa
32,557 Recognized Expert Moderator MVP
Another option is the Validation Rule property. That is there for exactly that purpose.
Oct 3 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

43
16005
by: dan baker | last post by:
I have a page that gets loaded with a meta-refresh hardcoded so that a few things on the page get updated. its kind of a fake chat board. anyway, what I need to do is turn off the meta-refresh once...
16
8448
by: Georges Heinesch | last post by:
Hi. My form contains a control (cboFooBar), which has an underlying field with the "Required" property set to "Yes". Now, while filling out all the controls of the form, I have to fill out this...
3
2994
by: Mark | last post by:
Access97 --- I set the Required property for a field at the table level and I have a form that contains that field. When I click the Close button at the top left of the screen, I get an error...
3
2202
by: ilushn | last post by:
Help! I am having a very aggervating problem with Access. Call me lazy, but I like to copy and paste addresses from Access into microsoft work, like for sending letters where I only need about 3...
3
5315
by: CindyRob | last post by:
I am using .NET framework 1.1 SP1, .NET framework SDK 1.1 SP1, with hotfix 82202, Visual studio .NET 2003 with hotfix 823639. I have generated a proxy class using wsdl.exe from a schema that has an...
2
4999
by: Billy | last post by:
Hopefully a simple one, what is the syntax to force a property to be required in a user control? I thought it would below, but it's not: Public Required Property propName() As String
11
3977
by: Naeem | last post by:
I have a Javascript function, which changes a text field of a form into a select field. Following is the function function changeStateField() { var myForm =...
0
1745
by: nimeshdotnet | last post by:
Hi All, I have a textbox whose readonly property is set to true. This textbox is also guarded by a required field validator. What i m doing that I have a calendar control whose on date selection i...
0
1057
by: robert112 | last post by:
Hi all, I have a WYSIWIG editor (fckeditor) and allow the users to create dynamic html which I save and display later on in the application. The aim is to have the user be able to create...
0
7193
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6975
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.