472,145 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

A reset Button for an Access Form

abouddan
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
5 11456
NeoPa
32,499 Expert Mod 16PB
You could try :
Expand|Select|Wrap|Line Numbers
  1. Call Me.Undo()
...from within your code.
Feb 19 '07 #2
nico5038
3,080 Expert 2GB
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
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
3,080 Expert 2GB
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
32,499 Expert Mod 16PB
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.

Similar topics

1 post views Thread by Joe Bloggs | last post: by
2 posts views Thread by angus | last post: by
1 post views Thread by NancyASAP | last post: by
3 posts views Thread by kashif_khan | last post: by
16 posts views Thread by Animesh K | last post: by
4 posts views Thread by tomb | last post: by
2 posts views Thread by azura | last post: by
reply views Thread by Saiars | last post: by
reply views Thread by leo001 | last post: by

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.