By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,466 Members | 1,599 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,466 IT Pros & Developers. It's quick & easy.

A reset Button for an Access Form

abouddan
P: 42
Hi all

I have an Access2000 form that contain many TextBoxes and a button. That button inserts the data in tables.
How can reset all the TextBoxes automaticly without doing that one by one and manualy?

Many thanks
Feb 19 '07 #1
Share this Question
Share on Google+
5 Replies


NeoPa
Expert Mod 15k+
P: 31,186
You could try :
Expand|Select|Wrap|Line Numbers
  1. Call Me.Undo()
...from within your code.
Feb 19 '07 #2

nico5038
Expert 2.5K+
P: 3,072
NeoPa is right, but the safest way is to use:

If Me.Dirty then
Me.Undo
endif

This will make sure no error message is triggered when performing an Undo on a form not yet filled.

Nic;o)
Feb 19 '07 #3

abouddan
P: 42
Thanks for your support.
I don't know why neither of the two sugestions works. I put a break point on
"If Me.Dirty ..." and when the code run, he stoped on it and when hovering on "Me.Dirty" the result was "False" eventhought that all TextBoxes are filled.
So I wrote this: "If Me.Dirty = False Then Me.Undo" . The code worked and the test was good but nothing happenned when running "Me.Undo" .
I did some researches and I found this code and it worked very well.

Expand|Select|Wrap|Line Numbers
  1. Dim ctlC As Control
  2. For Each ctlC In Me.Controls
  3.   If ctlC.ControlType = acTextBox Or ctlC.ControlType = acComboBox Then
  4.     ctlC.Value = ""
  5.   End If
  6. Next ctlC
Feb 20 '07 #4

nico5038
Expert 2.5K+
P: 3,072
The Me.Undo will only work for "bound" fields.
When you have unbound fields you'll need indeed such a loop to force the field(s) to be initialized.
It's however rare that you use unbound fields in Access as the bound fields are so easy to use :-)

Nic;o)
Feb 20 '07 #5

NeoPa
Expert Mod 15k+
P: 31,186
You're probably better off using Null rather than an empty string there. Null is typically used (and therefore more easily recognised) as an unset value.
Expand|Select|Wrap|Line Numbers
  1. Dim ctlC As Control
  2. For Each ctlC In Me.Controls
  3.   If ctlC.ControlType = acTextBox _
  4.   Or ctlC.ControlType = acComboBox Then ctlC = Null
  5. Next ctlC
Feb 20 '07 #6

Post your reply

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