473,659 Members | 3,631 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Conditional Fields

Greetings.

I have searched for an answer to my query for some time and have had no success. I'm hoping the pooled resources of all your brains can help.

How do you set a field to become active only if a certain condition is met?

I have several forms which are to be used for client booking and administration. Each has several fields which use a lookup across another table to ensure only valid values can be selected in those fields. I then have several fields to be filled out with text supplied by the user. What I want to do is set a conditional which will prevent anything being entered in those fields if the lookup field matches a certain value.

EG.

Referral Address
\/ _______________ ___
[Group 1]
[Group 2]
[Group 3]

Referral is a drop down field that extracts its values by lookup from another table. In this example there are 3 cases for address, being:
1) Address is mandatory (say if Group 1 is selected)
2) Address is optional (this is the basic state as form now stands)
3) Address field condition not met, and no data can be entered there.

such that end results would be
(on selecting 1st) [Group 1] [data must be entered]
(on selecting 2nd) [Group 2] [data may be entered if necessary]
(on selecting 3rd) [Group 3] [no data can be entered]

--------------------
So... how do I do this? Your help will earn you a small gold statuette engraved with the word 'Monsteriffic!'

Dexsquab

--
Message posted via http://www.accessmonster.com
Nov 13 '05 #1
3 1797
Well this may help and compared to many here i am a complete novice so
some may give you a better method.

You know you can make a macro conditional (right click in the header
and select conditions)
These conditions can then be used to interegate the value of the drop
down list and run after update to set the corresponding attributes of
the other controls on your form.

eg along the lines of

condition = dropdown=1 action = setvalue controlname.ena bled =
true/false

The macro can also be converted to code and you can use it in your own
coding.

As I said i am no expert but i hope it gives you a start
Hope it helps
Glyn

Nov 13 '05 #2
Use an If Then Else Statement or Select Case Statements.
Nov 13 '05 #3
Thanks for your assistance, however I still have had no joy.

I'll copy a code snippet, hopefully you can show me where I'm going wrong.

---------
Private Sub Referral_From_A fterUpdate()

If Me.Referral_Fro m = "Self" Then
Me.[Name_of_Referee].Enabled = False
End If

End Sub
------------

This code element appears in the After Update field on the Referral_From field. Similar code appears in Before Update and Change. It does nothing... no errors, no disabling of related fields. I've tried square brackets around the Referral_From element, which doesnt seem to help. Set up as above it seems as though the code doesnt exist.

If I change "Self" to 4 (the ordinal value from the referrer table), it then crashes with a run time error whenever that option is selected. The error is as follows:

Run-time error '2465':

Microsoft Access can't find the field '|' referred to in your expression.

So, is it bad variable naming, incorrect syntax, or what? Any help would be wonderful.

--
Message posted via http://www.accessmonster.com
Nov 13 '05 #4

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

Similar topics

3
5928
by: Jouke Langhout | last post by:
Hello all! For quite some time now, I've got the following problem: Access won't close properly when a user closes the application. An ACCESS process stays active and that process can only be terminated by pressing ++ and then terminate the process. I searched the entire internet and found out that there could be two things wrong (both of them are mentioned in the bug list on the access
5
2365
by: John Baker | last post by:
Hi: I have a field that i wish to use the conditional format capability on, and for some reason it wont work. The field is a a text box: =- I would like to make it red when negative, and have been working with the conditional
2
2959
by: Von Bailey | last post by:
I have a form where the conditional formatting is set on some fields to bold if certain conditions are met. However, when the conditions are met some of the data that is to bold is either not showing or only part of the data in the field displays (i.e. it will display the last name but not the first name or it will display neither). When the conditional formatting is removed it displays all the data as it should be display so the data...
2
1190
by: Sara | last post by:
The problem: Conditional formatting bold, red when field Value < date() sets the field background to white - always - whether condition is met or not. I want the field unfilled and just red/bold when the date has passed. Background: I have 2 related fields that are only rarely active, so I manage them in the query for the subform: ShowBlanket: IIf(,"Blanket","") and
4
1920
by: a | last post by:
I'm having trouble testing a custom object. I've tried many different approaches. One is shown below. The XML below shows the state of the object and I'm trying to test for that state, ie there are NO classes in the Classes collection (Classes) of the custom object. The conditional expression returns the error shown below it... =======================================================XML returned by
8
8483
by: Typehigh | last post by:
I have many text fields with conditional formatting applied, specifically when the condition is "Field Has Focus". Without any events associated with the fields the conditional formatting works perfectly. However, I have code that runs under the ON CLICK event. The code changes the focus to other controls, which means the conditional formatting is no longer displayed. This part makes sense to me. Here's what doesn't make sense. The last...
2
2949
by: audespero | last post by:
Hello, I'm a student tech at my college's campus library and i'm in charge of inventory for our A/V equipment this summer. I've decided to use access to tackle this task, and so far things are going alright, but the forms are getting a little long-winded. I want to make use of a drop-down menu with limitations, but It's been a few years since i've used access, and i'm having a terrible time finding any helpful information online because i'm...
2
3109
by: Filips Benoit | last post by:
Dear All, Access 2003 adp on SQL_server 2005 A continious form showing 1 month based on table 'CALENDAR_MONTH_GRID' and fill with a SP. Fields: Companyname, Day1, day2, etc. The value in the day-fields is like WK (weekend), NH (National holiday), etc. Depending on the fieldvalue the field is colored using conditional
2
1691
by: Paul | last post by:
Can you help me with this error? string fields = string.Empty; .... fields.Length 0 ? fields += ", Name" : fields += "Name"; Error: Only assignment, call, increment, decrement, and new object expressions can be used as a statement
0
8428
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8337
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8531
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8628
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4175
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2754
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 we have to send another system
2
1978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.