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

Creating a reset/clear button for a form

Good Afternoon,

I have been trying to figure this out for days. I have a search form in Access 2007 that is unbound with unbound text boxes. The submit button works great, but I am trying to creat a clear button so that the user can clear out their information at once instead of each individual field. My form name is SearchingForm and the text boxes are clientname, operatingstate, product. I have tried the following codes:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub resetbtn_Click()
  3.  
  4. Me.Refresh
  5.  
  6. End Sub
  7.  
  8.  
also tried

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub resetbtn_Click()
  3.  
  4. Me.clientname = ""
  5. Me.operatingstate = ""
  6. Me.product = ""
  7. Me.Refresh
  8.  
  9. End Sub
  10.  
  11.  
Any help would be appreciated. I have not used Access or VB in years, so I am trying to relearn for work. Thanks
May 6 '14 #1

✓ answered by Seth Schrock

Try going to Access Options>Trust Center>Trust Center Settings>Message Bar. Make sure that the option to Show the Message Bar in all applications when active content... has been blocked is selected. Then close the database and open it again. See if you get a yellow bar telling you that some content could be harmful and was disabled. If it does, click enable content and then try your button.

28 37551
Seth Schrock
2,965 Expert 2GB
The refresh isn't needed. What happens with your second block of code? Do you get an error message or does it run and just not clear the fields?
May 6 '14 #2
Thank you for the quick response. On either block of code that I try it does nothing, just sits there. I have also tried the = Null instead of the = "". Just to clarify on the code that I listed it was not in there at the same time, that is code that I tried on two different attempts at trying to get it to work
May 6 '14 #3
Luk3r
300 256MB
So, your textboxes are named: clientname, operatingstate, and product?
May 6 '14 #4
Sorry for the delay. Yes the three text boxes are named the above. (no capitalization and no spaces).
May 6 '14 #5
Luk3r
300 256MB
Have you tried:
Expand|Select|Wrap|Line Numbers
  1. Me.buttonName.Value = ""
May 7 '14 #6
Yes, I have tried that as well and had the same response - nothing happened.
May 7 '14 #7
Seth Schrock
2,965 Expert 2GB
This makes me think that your code isn't running. Try typing STOP right before your code and then click your Clear button and see if the code stops at that line.
May 7 '14 #8
Ok I just tried that, but I am not sure what it is suppose to do. I get the same result. I have the code open when I am clicking on the clear button and I see nothing happening. Thanks so much for all of the help with this. Here is the code that I have put in

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. Private Sub resetbtn_Click()
  4.  
  5. Stop
  6.  
  7. Me.clientname = ""
  8. Me.operatingstate = ""
  9. Me.product = ""
  10.  
  11. End Sub
  12.  
  13.  
May 7 '14 #9
Seth Schrock
2,965 Expert 2GB
Ok, if the code was actually running, then the code would have stopped with your Stop line highlighted. Go to your Reset button's event list in the properties window. Click in the On Click event line and then click the ellipsis button. If it is attached to your code, it will take you to it. If not, then it will either take you to the code window and create a new event sub or it will ask you what you want to create. If the later, then choose the code option and click OK. That will then create a new event sub and then you can put your code in that one and delete your old one.
May 7 '14 #10
I did that and it took me to my code.
May 7 '14 #11
jimatqsi
1,271 Expert 1GB
So it sounds like you wrote the code where it should have been, named as it should have been, but did not wire it up to the event. Now that you've done that, I suspect your click will work.

Jim
May 7 '14 #12
You would think that would be the case, but it is still not working. I am not sure what I am doing incorrectly - but for some reason it is still not working.
May 7 '14 #13
zmbd
5,501 Expert Mod 4TB
OP:2ndBlock:line7:Me.Refresh

change to

OP:2ndBlock:line7:Me.Repaint

post back results if any.
May 7 '14 #14
Seth Schrock
2,965 Expert 2GB
Try going to Access Options>Trust Center>Trust Center Settings>Message Bar. Make sure that the option to Show the Message Bar in all applications when active content... has been blocked is selected. Then close the database and open it again. See if you get a yellow bar telling you that some content could be harmful and was disabled. If it does, click enable content and then try your button.
May 7 '14 #15
Seth - I checked and that option is selected in the trust center

Zmbd - Do you want me to just put Me.Repaint and leave out the specific textboxes?
May 7 '14 #16
Seth Schrock
2,965 Expert 2GB
Did you close and then reopen your database?
May 7 '14 #17
Zmbd - I tried Me.Repaint with the textboxes listed and without and nothing. It is like it isn't even going to the code. Here are the three codes that I tried at 3 seperate times.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub resetbtn_Click()
  3.  
  4. Me.clientname = Null
  5. Me.operatingstate = Null
  6. Me.product = Null
  7. Me.Repaint
  8.  
  9. End Sub
  10.  
  11.  
Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub resetbtn_Click()
  3.  
  4. Me.clientname = ""
  5. Me.operatingstate = ""
  6. Me.product = ""
  7. Me.Repaint
  8.  
  9. End Sub
  10.  
Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub resetbtn_Click()
  3.  
  4. Me.Repaint
  5.  
  6. End Sub
  7.  
I am at a loss as to what I am doing incorrectly.
May 7 '14 #18
Seth - that was the setting in the trust center when I went in there, I didn't have to change anything
May 7 '14 #19
Seth Schrock
2,965 Expert 2GB
I realize that. But you still need to close and reopen the database to then get the message to popup. Most people just hit the X when they see the message and don't even think of it. Once closed, it won't pop up until you close and reopen the database, hence why I'm recommending that you try it. The option being already set, as it is by default, doesn't means that closing and reopening the database is pointless.
May 7 '14 #20
Oh Ok Sorry about that. Let me try it again then
May 7 '14 #21
Wow that worked. Thanks sooooooo much for the help. So glad. Is there a way to keep it enabled for that code though? When I go back out of the database and come back in it doesn't work again unless I enable it.
May 7 '14 #22
Seth Schrock
2,965 Expert 2GB
You can add the containing folder to your trusted locations.
May 7 '14 #23
Ok, how do I do that?
May 7 '14 #24
Seth Schrock
2,965 Expert 2GB
In the same trusted locations box, instead of selecting the Message Bar tab, choose Trusted Locations and then click Add New Location and then you can browse to the folder that contains your database and then click OK.
May 7 '14 #25
Just tried it and my work does not allow me to do that. So I will have to see if I can have an IT person do it for me. Thanks again for your help
May 7 '14 #26
Seth Schrock
2,965 Expert 2GB
I'm glad that I work in IT and have admin privileges on my computer :)
May 7 '14 #27
Yeah I wish that I did. :)
May 7 '14 #28
This was very helpful thank you!
Jun 12 '18 #29

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

Similar topics

5
by: Matt | last post by:
I want to write a generic clearForm function to clear the form when the user click CLEAR button. Here's my attempts, because I want to take care all html controls. I think I need to test if the...
0
by: Hohn Upshew | last post by:
My problem is that after chosing an order from the list and open a report, the form stays with the number of the customer for that number and cannot be requeried.How can i clear the form? This is ...
0
by: Doslil | last post by:
I have a form which is designed to only data entery.When i try to open to form in the run form I have the following errors 1. when i open the form I get an error message saying "Access can't...
3
by: Infidel | last post by:
Hi there, Can anyone tell me how I can stop this from happening. Basically, I'm using validation controls on a form which works great... but, perhaps a little TOO great. When I click Clear......
1
by: Kittie | last post by:
Hello, I'm pretty new to web programming and i'm facing an issue. Hope someone can help! I have a LinkButton in a form and when i click on it, it posts back to the page. The problem i want to...
1
by: johnacooke | last post by:
I have a HTML form that is generated in part by PHP. The action attribute on the form tag calls itself, so that I can validate the fields without using any other form of code like Javascript to...
1
by: Mark Daniel | last post by:
I have attached the coding that I have so far. I am a beginner, and I am self teaching through a book. I can't figure out why my System.out.println isn't displaying anything, also I have a clear...
2
by: Sophia Olivas | last post by:
I have this form that acts like Paint - i want to be able to clear the form with the click of a button. I tried form1->Clear();
5
by: cazbarr | last post by:
Hi all, I have created a form using a table. I have created a reset form and a send email button. I thought my reset button would clear my form, but this is not happening and I am not sure if...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
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,...
0
isladogs
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...

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.