I'm trying to use VBA code to disable a field based on the value of another field in a form. The code I have properly updates the enabled property of the field when it changes; however, it changes it for the form as a whole instead of a single record. My form is set as a single form.
For example on record 1, field1's value is "records" and field2's enabled property is set to false. When I go to the next record (record 2), field2's enabled property remains set to false even though field1's value is now "measurable " which should make field2's enabled property as true. Here's the code I have right now: - Private Sub Field1_AfterUpdate()
-
Me.Field2.Enabled = True
-
If Me.Field1 = "records" Then
-
Me.Field2.Enabled = False
-
ElseIf Me.Field1 = "measurable" Then
-
Me.Field2.Enabled = True
-
End If
I've tried using a requery setting on the form and also on field1's properties of GotFocus, but I haven't had any success. Any help would be greatly appreciated.
Thanks!
5 3582
Anytime you do something like this in the AfterUpdate event you also have to place the same code in the Form_Current event in order to persist the formatting as you move from record to record.
Welcome to Bytes!
Linq ;0)>
Also, adding DoEvents after text field changes forces an immediate screen update instead of waiting for a later time. For many situations, it is the only way you are going to see the change.
Also, adding DoEvents after text field changes forces an immediate screen update instead of waiting for a later time. For many situations, it is the only way you are going to see the change.
What are you talking about? DoEvents is not needed for the OP's code to work under any circumstance that I'm aware of! In point of fact, his code was changing the Enabled state of the other control without problem. The problem was that when Field2 was disabled in RecordA and the user moved to RecordB Field2 was also disabled there. Placing the code in the Form_Current event solves this. DoEvents is primarily used to fix timing issue problems. It returns control from Access to Windows so that Windows can complete an operation, such as printing a report before Access tries to start printing a second report, or completing the running of one query before running another query, where the first must be completed before the second can be run with the correct results.
Linq -
I added my code to the form's OnCurrent property and it does exactly what I want. Thanks for your help!
Glad we could help!
Linq ;0)> Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Rob Dixon |
last post by:
Hi.
Am I missing something, or is there no way of greying out
irrelevant form fields on the basis of the contents of the
rest of the form?
Thanks,
Rob
|
by: Greg |
last post by:
I am trying to change the value of one field in my query based on the value
in another. If Field 1 had the text "ONACCNT" then in Feild 2 I want the
date to change to today's date. Any help would be great!
Thanks,
Greg
|
by: Jim |
last post by:
Hey all, I have a dilemma.
I have a field in a table called "Supervisor." The table currently
has 1,500+ records. Sometimes, the HR download that populates the
field formats the field one way, sometimes another. For example, I
may get records such as follows:
Supervisor
Hall,John J.
Hall, John J
|
by: Danny |
last post by:
Hello
I am trying to create a separate listbox and fill it with items based on
what is in another field in a database.
This field is bound to a field in the underlying database. But the data is
changed from another list box that is a pulldown of the 3 items. This way
they are forced to select one of the 3 items.
So when the field updates based on the item chosen, why doesnt it cause the
"on change event" to happen? The field has...
|
by: Lyn |
last post by:
Hi,
Can anyone tell me how the initial value displayed in Combo Box is
determined when a form is opened?
I am loading the dropdown from one field ("CategoryName") of a table, with
"ORDER BY ". The values in the dropdown are loaded in the
correct order, but the initial value is not the first row of the dropdown as
I expected.
The field "CategoryName" is not the primary key for the table -- the PK is
| |
by: Ray Holtz |
last post by:
Is it possible to autofill a field based on what is entered into another
field in a form? My form has an employee field, and department field.
In an Items Table, I have fields FldEmployee, and FldDepartment.
FldEmployee is looked up from an TblEmployee Table which also has fields
FldEmployee and FldDepartment. This FldDepartment field is looked up
from a TblDepartment table that just has FldDepartments. I hope I
explained that OK
The...
|
by: astro |
last post by:
Anyone have suggestions on where to troubleshoot this error?
Background:
-Access 2k v. 9.0.6926 sp3
- front and backend on production server (wiindows 2k)
-accessed via Citrix
-front-end is mde, backend is mdb
-only occurs on the production server
-only occurs with mde verson - i've tested the problem with the mdb version
of the front-end and it loads/generates the document fine on the production
|
by: AA Arens |
last post by:
Somebody willing to assist me in the following?
I want to have values from one field copied to another field when I
choose choose a item from a drop down menu.
I have 2 forms:
1 Company contact info
2 Employee contact info
When I finished form 1, I jump to form 2.
|
by: lsimonelli via AccessMonster.com |
last post by:
On a form, how do I require entry of a field based on the data in another
field? I do not want to require at the table level.
I have a field that the user selects where a refund goes. If they choose
"Other", field "Other Explanation" cannot be Null. If they choose
"Producer" then field "Producer Code" cannot be Null.
Your help would be greatly appreciated!!
--
|
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...
|
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,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |