473,395 Members | 1,815 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,395 software developers and data experts.

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 1784
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.enabled =
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_AfterUpdate()

If Me.Referral_From = "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
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...
5
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...
2
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...
2
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...
4
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...
8
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...
2
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...
2
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...
2
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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...
0
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.