Currently I am manually setting each control on my form to null to reset. Does anyone know how to do this with a loop or a more simple command? I've seen some make shift control arrays but none that would work for me.
Thanks,
Aric
12 15942
Currently I am manually setting each control on my form to null to reset. Does anyone know how to do this with a loop or a more simple command? I've seen some make shift control arrays but none that would work for me.
Thanks,
Aric
Try - On Error Resume Next
-
-
Dim ctl As Control
-
For Each ctl In Me.Controls
-
ctl.Value = Null
-
Next
I've tried something like that but I get the error that the object doesn't support that property/method.
NeoPa 32,556
Expert Mod 16PB
If you look carefully you'll see that there is code included to avoid that situation arising (On Error Resume Next).
Try this code out as exactly as possible and let us know how you get on.
At worst you'll waste five minutes.
If it doesn't work properly for you then come back and let us know what went wrong and we'll see if we can't find another solution for you.
I think I got it fixed, here is the code I used, (an interesting work around): -
Private Sub ResetFields()
-
Dim ctlTextBox As Control
-
-
For Each ctlTextBox In Me.Controls
-
If TypeName(ctlTextBox) = "TextBox" Then
-
ctlTextBox.Value = Null
-
End If
-
Next ctlTextBox
-
-
-
End Sub
-
And I'm using this for combo boxes: -
For Each ctlComboBox In Me.Controls
-
If TypeName(ctlComboBox) = "ComboBox" Then
-
ctlComboBox.Value = Null
-
End If
-
Next ctlComboBox
-
NeoPa 32,556
Expert Mod 16PB
Maybe this could work better for you (similar results of course - just tidier code). - Private Sub ResetFields()
-
Dim ctlTextBox As Control
-
-
For Each ctlTextBox In Me.Controls
-
If TypeName(ctlTextBox) = "TextBox" _
-
Or TypeName(ctlTextBox) = "ComboBox" Then _
-
ctlTextBox.Value = Null
-
Next ctlTextBox
-
End Sub
PS. It would be interesting, for me as well as any future readers of the thread, if you could post what happened when you tried ADezii's code.
It would be interesting, for me as well as any future readers of the thread, if you could post what happened when you tried ADezii's code.
If you use this code: - Dim ctl As Control
-
For Each ctl In Me.Controls
-
ctl.Value = Null
-
Next
You will get the following Error Number: 438 Error Description: Object doesn't support this method or property.
NeoPa 32,556
Expert Mod 16PB
I understand that Aric, but that wasn't the code posted.
You left out a very important line :
which should ensure that the error is never triggered but that all controls (Text- & Combo-Boxes) that can be set to Null are (See Post #4).
I understand that Aric, but that wasn't the code posted.
You left out a very important line :
which should ensure that the error is never triggered but that all controls (Text- & Combo-Boxes) that can be set to Null are (See Post #4).
I didn't use that line in my testing, only the for loop. I log my errors with error handling. Sorry for the confusion.
NeoPa 32,556
Expert Mod 16PB
Not a problem Aric.
And congratulations to you for becoming a TSDN Moderator.
Not a problem Aric.
And congratulations to you for becoming a TSDN Moderator.
Thanks Adrian, glad to help out! I appreciate all the help I get in the Access forum.
Thanks Adrian, glad to help out! I appreciate all the help I get in the Access forum.
Aric
If your form is unbound would Me.Refresh not work.
Mary
I had this same problem, thanks to all for your help
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Yasutaka Ito |
last post by:
Hi,
As you know, all the non-ui components (like Timer control, etc.) that sit
on the form are contained in its private variable 'components'.
How can I enumerate such components from any form...
|
by: Jozef |
last post by:
I have some old code that I use from the Access 95 Developers handbook. The
code works very well, with the exception that it doesn't seem to recognize
wide screens, and sizes tab controls so that...
|
by: Chris |
last post by:
Hi,
I'm trying to append text from another class to a generic richTextBox that
I've added to a Windows form. I can't seem to figure out how to expose the
richTextBox to append text to it.
...
|
by: Jaikumar |
last post by:
Hi,
1) I have created one windows application, In the main form ( form1) i have added one usercontrol (usercontrol1), In that user control i am drawing one image.
2) In the UserControl1 i am...
|
by: Claus Holm |
last post by:
I'm trying to enable a menuitem in the parent form from a mdichild. Rather
than making the menuitems public, I'd go for a public method in the parent
form to do the change, but when I call the...
|
by: Johnny |
last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form
(fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip
code. The user can enter a zip code in the text box and...
|
by: Johnny |
last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form
(fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip
code. The user can enter a zip code in the text box and...
|
by: John Boy |
last post by:
Hi,
Can anyone help. This is really doing my nut in. 3 years ASP exp. and
now doing .DOT which is a step in the wrong direction.
Basically I am left with the code of a guy who has left. When I...
|
by: ahmad.humyn |
last post by:
I want to call a hidden form. My code goes something like in which the
main calls form1. form1 has a button which creates & calls form2 and
hides itself. Now I have a button in form2 which if...
|
by: Toze |
last post by:
I'm using a assembly to load my apllication (ex: Mobi.exe), and now I need to
list all forms in my apllication and list all controls (ex: txtname;btnname)
inside of each form.
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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: 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...
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
| |