473,385 Members | 2,005 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,385 software developers and data experts.

conditionally enabling a form control

Perhaps someone in this group smarter than me can help me with this
problem. On a data entry form, I have placed a command button to
"close" the form when the user is finished entering the required data.
To make sure the user enters complete data in every text control, I
have set the button's "enabled" state to false when the form loads. I
have placed the following code in the form's general code section.
Other than the command button, the controls on the form consist of two
text boxes and one combobox in that order. I call the following
subroutine from each of the control's "OnChange" Events, but it does
not change the command button's state to "enabled." I've tried calling
the procedure from other control events like AfterUpdate, Dirty, etc.,
but no luck.

Thanks
Scott

Dim frmName As String
Dim ctl As Control
Dim X As Boolean

frmName = Me.Name

For Each ctl In [Forms]!frmName
If IsEmpty(ctl) Or IsNull(ctl) Then
X = False
End If
Next ctl

cmdDone.Enabled = X

Nov 13 '05 #1
2 1795
Scott wrote:
Perhaps someone in this group smarter than me can help me with this
problem. On a data entry form, I have placed a command button to
"close" the form when the user is finished entering the required data.
To make sure the user enters complete data in every text control, I
have set the button's "enabled" state to false when the form loads. I
have placed the following code in the form's general code section.
Other than the command button, the controls on the form consist of two
text boxes and one combobox in that order. I call the following
subroutine from each of the control's "OnChange" Events, but it does
not change the command button's state to "enabled." I've tried calling
the procedure from other control events like AfterUpdate, Dirty, etc.,
but no luck.

Thanks
Scott

Dim frmName As String
Dim ctl As Control
Dim X As Boolean

frmName = Me.Name

For Each ctl In [Forms]!frmName
If IsEmpty(ctl) Or IsNull(ctl) Then
X = False
End If
Next ctl

cmdDone.Enabled = X


You dimmed X as boolean with a default value of false. So you cycled
through the text fields and no matter if they are all filled in or not
you will always have a false value.

Set x to True before you start scanning the controls.

I'm not sure you need to check using IsEmpty(). However, a numeric
value may default to zero. Do you allow zeros?

BTW, you might want to check if the CTL is acTextBox so you aren't
scanning isn't a label or command button or list box. See ControlType
in help.

Nov 13 '05 #2
Thank you very much. I missed that small but critical piece of logic.
Scott

Nov 13 '05 #3

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

Similar topics

3
by: Bryan Capps | last post by:
I have a text box control on a form, the value of which is calculated (concatenated) from entries on a subform. Accordingly, I've set the control's locked property to true and the tab stop...
2
by: HumptyDumpty | last post by:
Does anyone know if there is a problem with re-enabling the Screen Saver after it has been disabled programmatically. I am using the SystemParametersInfo function within User32.dll, and have...
1
by: Reddy | last post by:
Hi, My web form has a dropdown list and a textbox server controls. The user must enter some text in the textbox he selects only the last item in the dropdownlist. I tried using a custom...
2
by: Paul | last post by:
Just wondering if anyone knows how to conditionally load a user control on a page? In other words load the user control if the page is reached with one link and do not load it if it is reached by...
3
by: Tumurbaatar S. | last post by:
I'm trying to dynamically hide/show a HTML table server control. My form contains one CheckBox control and its AutoPostBack set to true. The Checked value of this box controls whether to show or...
2
by: Jens Weiermann | last post by:
Hi, I need to conditionally disable a html (not web forms) button control. The condition is to be evaluated server-side. What is the smartest way to do this? I'm now using a literal server-side...
5
by: henry | last post by:
Basically, my php script runs on my serve all day along. If the php script finds something new, I'd like to get an email alert(which is done) and a cell phone alert, which has to be done through a...
4
by: nickvans | last post by:
Hello, and thanks in advance for helping me out. I have a form which filters data in numerous ways. I have set up the form such that Access will only filter a given category if a checkbox next to the...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
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...

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.