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

VBA code to disable field on form

I wrote a little database to keep track of employee time. After the pay period ends, we need to be able to programically change specific fields on the form to read-only.

Specifically, when the payroll period for October 17-30 ends, I'd like to create a button the payroll clerk can hit that will make the fields for those dates to change from Enabled=Yes, to Enabled=No. I'd like it to start on October 17, then step through the procedure 13 more times.

I'mve signed up for VBA classes, but they haven't started yet. I can program a little, but I'm not a proficient programmer right now, and I currently lack the skills to write this code.

Any suggestions?
Oct 21 '10 #1
3 9867
dsatino
393 256MB
Create a button on the form.
In the onClick event of that button put something like this:
Expand|Select|Wrap|Line Numbers
  1. Me.Controls("TEXTBOXNAME").Enabled = False
  2.  
Oct 21 '10 #2
NeoPa
32,556 Expert Mod 16PB
You can use either :
Expand|Select|Wrap|Line Numbers
  1. Me.TextBoxName.Locked = True
or :
Expand|Select|Wrap|Line Numbers
  1. Me.TextBoxName.Enabled = False
The principle difference being that .Locked = True disables use but .Enabled = False does that, as well as showing the control as greyed out somewhat.
Oct 21 '10 #3
OldBirdman
675 512MB
I assume the data is normalized. The time data would be in a related table with a foreign key to the employee table. I would expect an UPDATE Query would be appropriate here to mark each record within the time period (October 17-30) in the example given. This would require a Completed field (Yes/No) on each day's record be updated to 'Yes' in the UPDATE query.

If the time data when shown in form view is Continuous Forms, then Conditional Formatting will be necessary to set .Enabled to False for the appropriate fields.

If the time data is in the employee table, and the form view is always Single Form, then Conditional Formatting is not necessary. .Enabled can be set in the form's OnCurrent event.

Additionally, there should be a method to unlock/enable the fields again if an error is discovered that must be fixed.
Oct 21 '10 #4

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

Similar topics

3
by: John Hrusovszky | last post by:
I have not been able to figure out how to run code in a form, before any buttons are pushed/clicked. What I have is a recipe manager that "reads" an access file to get recipe information. When a...
1
by: Shabam | last post by:
Is there a way to present a form to a user by default with all forms disabled, then when user clicks a link, the fields become enabled?
2
by: Jozef | last post by:
Hello, I have a form in which I've created a public function. That function calls some private code within that form. I'd like to run this code from another form. I know I've done this before...
3
by: Yuelin | last post by:
Hi there How can I disable a form being resized? i can't find a property in the property window to do this. Thanks yuelin
21
by: Simon Verona | last post by:
Hope somebody can help! I want to automatically be able to add code to the initialize routine on a Windows form when I add a custom control that I've written to a form. Specifically, I'm trying...
4
by: hassan | last post by:
I want to add a function in parent form of a custom component from component. How this is possible.
0
by: Mark | last post by:
Hello I'm using VS2005 and doing a VB.Net project. Yesterday I changed one of my forms by removing a listview and a couple of buttons (contained in a tab page). These were recreated in a user...
1
by: WELCOME ### | last post by:
Hi all From Beginner: The below is simple program written with C++/ CLR Console; showing the weights for each of 3 persons as: ============================ #include "stdafx.h" using namespace...
10
by: Raman Pahwa | last post by:
I have an ASP code with a form in that.I have 2 text boxes and a submit button.I enter data in text boxes and then click on submit. then action I want takes place.but when i go to previous page to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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...
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.