473,395 Members | 1,574 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.

Textbox enabling from Command button.

Lensmeister
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 is that when the command is clicked, ALL the textboxes are then enabled (and the one checkbox is set to unchecked).

Therefore the logic path of this should be
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command26_Click()
  2.  
  3. object.enable = true
  4. object.checked = false
  5.  
  6. End Sub
  7.  
So the code should read:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command26_Click()
  2.  
  3. Name.enabled = true
  4. SignedDate.enabled = true
  5. SignedFrom.enabled = True
  6. AttheClub.checked = False
  7.  
  8. End Sub
  9.  
But this has not worked. Can someone advise me where I have gone wrong please ?

Thanks in advance.

Lensmeister.
Mar 11 '09 #1
11 4635
Stewart Ross
2,545 Expert Mod 2GB
There is nothing obviously wrong from what you have shown us so far. Are you sure that the code is being run? There are no other syntax errors that would prevent the code module from running (simply checked by compiling the code)?

You can check to make sure that the event code is being run by setting a breakpoint in the last line of the sub. When the on-click event fires and the code is run the breakpoint will suspend code execution on the line concerned. If it does not suspend then the on-click event code is not actually associated with the on-click property of the control. This can happen if, for example, you change the name of a control and forget to change the name of any associated event handlers.

If the breakpoint does suspend the code it will give you the opportunity to check the status of each control's enabled property in the immediate window, by typing

? [controlname].enabled

or just by hovering the mouse over the relevant property in the VBA editor window.

By the way, you can check that you have the correct control names listed by using the shortcut Me property of the form followed by a period - this will list all object properties for the form, and if you then type the first letters of the control concerned you should see the control named in the list (with any spaces in its name replaced by underscores).

If you type, for example, Me.At then the Intellisense should show you all matches for that name - notably the AtTheClub control you mention. If it doesn't, the control would not appear to exist for that form. This may arise if the objects concerned are located on a subform instead of the mainform, or vice-versa.

-Stewart
Mar 11 '09 #2
Thanks Stewart,

I will try this later.

Lensmeister.
Mar 11 '09 #3
NeoPa
32,556 Expert Mod 16PB
One of your controls appears to be called Name. It is not recommended to reuse names with pre-existing meanings (such as Name). This is possibly not a problem for the compiler, but it's good policy, when this is deemed necessary (should never be so), to refer to them more explicitly, such as Me.Name. Name is one to avoid particularly, as it's clear now I type it that it already exists even as Me.Name. I suggest you consider making a rule for yourself never to use names like Name, or Date, or anything else which is likely to clash with something else.
Mar 11 '09 #4
I will rename it (if it is a good idea)

txtName

'Name' is the title of the field in the Access DB. and I created the form with the wizard so it took that at the name of the control.
Mar 11 '09 #5
NeoPa
32,556 Expert Mod 16PB
It certainly is a good idea. I'm always embarrassed to hear that a dodgy name was created by the wizards. Designed by the same company that tries to teach us how best we should organise our code. Ironic I suppose. Their advice is generally quite good mind you. Just their inability to follow it themselves is a bit of a giggle ;)
Mar 11 '09 #6
missinglinq
3,532 Expert 2GB
Stew mentioned the control AttheClub and I thought he'd hit on the snag in the code, but then he went somewhere else with it. But if you continue the line of thought, if you type in

Me.AttheClub.c

a dialog box will pop up listing all the Properties available for the control AttheClub that start with the letter "C." The first one, I believe, is ColumnHidden, which means that there is no Property named "checked."

So

AttheClub.checked = False

is incorrect syntax. What you mean to say is that the Value of AttheClub is False, No or 0 (Zero.) Since Value is the Default Property of a Checkbox, you can omit it and simply write it as

Me.AttheClub = False.

Don't know if this, along with the previous advice, about renaming your control and using Me. in order to take advantage of Intellisense, will solve all of your problem ("this has not worked" is not really very descriptive) but it will cause a error to pop, and the change is necessary if you want your checkbox to be unticked.

Welcome to Bytes!

Linq ;0)>
Mar 11 '09 #7
Stewart Ross
2,545 Expert Mod 2GB
Lensmeister, you'd do well to take heed of the excellent points made by Linq, and also what NeoPa mentioned re names (wizard created or not!).

I suppose I was being a little oblique when I mentioned compiling your code. If you get into the habit of compiling any changes to your code the compiler will automatically catch as errors any references to non-existent object properties, at least if you refer explicitly to the objects concerned, as for example in

me.control.someproperty

My suspicion was that the code was not being executed at all, as if it was there should have been a run-time error when you tried to refer to a property such as checked that is not valid.

-Stewart
Mar 11 '09 #8
Thanks guys the info has been noted and I will update the names of the controls.

I decided to take another tack on the enable = True/False etc.

I do need the controls on the form, but not able to be edited. Locked seemed like a better solution. Taking the info above I had a go at editing the code accordingly and now It is working well with the locked property being set to true on form load and when the command is clicked it changed the property of all the controls to unlocked.

Thanks a lot chaps :)

This is the best forum for help and info and I am learning more than I have on other forums. It's a lot more friendlier too.

Thanks again :)
Mar 12 '09 #9
missinglinq
3,532 Expert 2GB
Glad we could help, Lensmeister!!

Linq ;0)>
Mar 12 '09 #10
Thanks Stewart,

I have it working now :)
Mar 12 '09 #11
NeoPa
32,556 Expert Mod 16PB
I split the latest question away into its own thread (Sorry for the bad timing Stewart) - Select on CheckBox.
Mar 12 '09 #12

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

Similar topics

2
by: Scott | last post by:
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...
2
by: dskillingstad | last post by:
I'm trying to assign a custom value to a textbox. Here's what I have. I've created a module and "default value" code for a textbox which generates a custom auto-number (yyyy-0000) when a New...
0
by: Andrea Trevisan | last post by:
That's a revival of a known thing I suppose.I hope it's useful. My problem was: I want to have a DataGrid with two Template columns: first with TextBox,second with Button.I want to fire an event...
0
by: jason | last post by:
Hello everyone. I am trying to write some custom command events into a DataGrid. The command that is currently giving me trouble is an "Add" custom command in the footer of a template column. ...
6
by: JohnR | last post by:
I have a table with 1 row which is used to hold some application wide items (one item per field, hence I only need 1 row). I want to bind one of the fields to a textbox. After setting up the...
5
by: Stuart Shay | last post by:
Hello All I am working on ASP.NET 1.1 Custom Pager that allows a User to Enter a Number in a TextBox and go to the page selected. Since the OnClick Event does not work in ASP.NET 1.1 for a...
2
by: metalwing12 | last post by:
hi guys can someone help me out here.im having a hard time doing this project well this is my code I try using the disabled property of the textbox yes it workss, it disable it but when i set it to...
3
by: kimiraikkonen | last post by:
Hi experts, I just want to ask a simple procedure of my simple form. My form has a input textbox and a button. I want this if you can help me: Application user types a command prompt command...
3
by: Mike | last post by:
Is there a way to determine if a user deleted text in a asp:textbox? I have a textbox were users can enter in a product number, then they click a button to see if the product numbers(s) exists in...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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
tracyyun
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...

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.