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

Make a command button enabled

65
Hello,

I have an unbounded text box which have a default value of Zero (0). And a command button which is not enabled and will save the value in the text box when pressed.

What I want is that: When I change the default value in the text box, I want the command button to be changeed to enabled. I want this action to be taken just when I start typing in the text box.

Thank you for your help,
Abolos
Apr 27 '07 #1
4 2723
pks00
280 Expert 100+
txtbox is called txt1, commmand button is called Command4

Expand|Select|Wrap|Line Numbers
  1. Private Sub Txt1_KeyPress(KeyAscii As Integer)
  2.     If Me.Txt1.Text & Chr$(KeyAscii) <> "0" Then Command4.Enabled = True Else Command4.Enabled = False
  3. End Sub
  4.  
Apr 27 '07 #2
abolos
65
Thanks for your reply. But actually it didn't work as I want. Because suppose you want to clear the text by backspace, then the button will stay active while it has to be inactive.

But I found a solution for this. And it is:

If Val(txt1.Text) > 0 Then
Command4.Enabled = True
Else
Command4.Enabled = False
End If


Thanks anyway
Apr 27 '07 #3
pks00
280 Expert 100+
Ok, I did it on the understanding that u wanted it disabled when u had your default value of 0. To me it wasnt quite clear that u wanted it disabled when nothing was selected.

Did u know already to use the Keypress function and also to use the .Text property and not .Value?
Apr 28 '07 #4
abolos
65
Ok, I did it on the understanding that u wanted it disabled when u had your default value of 0. To me it wasnt quite clear that u wanted it disabled when nothing was selected.

Did u know already to use the Keypress function and also to use the .Text property and not .Value?

Sorry for the delay and thanks for your reply. Yes i know the Keypress function.

Abolos
May 23 '07 #5

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

Similar topics

2
by: Robert | last post by:
I am using the php4-cgi Debian package which is based on PHP 4.3.4. I have problems when running php4 on the command line. If I say something like $ php4 index.cgi a number of variables...
2
by: Colin | last post by:
I have a main form with a command button on it that when clicked, opens a subform displaying records that relate to the main form. I would like to disable the command button if the corresponding...
4
by: Arif Çimen | last post by:
Hi to everybody, I have chnged a button text in design mode. But After compiling and executing the program the text of the button do not change to new value. Any Ideas? Thaks for helps.
7
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about...
0
by: Keithb | last post by:
My application has a LinkButton that I am using as a Command button in the ItemTemplate of a GridView control. Regardless of the value set for the Enabled property (true or false), The control is...
7
by: pushrodengine via AccessMonster.com | last post by:
I have a command button “AddIncidentâ€. I would like to make it so that it will not add the record to the database if textbox “Type†is empty. I also would like to add a message that will...
2
by: dstork | last post by:
Anyone know how to rename the "Exit Access" command at the bottom of the Office menu. I'd like to rename it to "Exit" as I had done in previous versions of Access. I know I can disable it with ...
3
by: skanemupp | last post by:
is there anyway to make this shorter? i hate having these big blocks of similar-looking code, very unaesthetic. maybe doesnt matter good-code-wise? anyway can i make some function that makes this...
11
Lensmeister
by: Lensmeister | last post by:
Hi everyone, I have a form with a number of textboxes on it. These are initially set ot enabled = no in their properties. On the form is a command button named command26. the event I want...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.