Clear all controls on a form

T

T.

Sorry for posting this again but I really need some help....

Hey all,

I need to write a script that will go through all the controls on my forms
and clear them. I have something that sets values to Null and "" but when
users try to save something or close the form they always get warnings about
not having a primary key and telling you that you can't save it, then it
asks you if you want to close it anyways, say yes and all is ok.

Is there a way so that you can go into the form put in some data, clear it
all and then close the form without getting those stupid warnings?? If you
just open the form and close it without touching anything it doesn't give
warnings at all.

TIA,

T.
 
J

Jonathan Parminter

-----Original Message-----
Sorry for posting this again but I really need some help....

Hey all,

I need to write a script that will go through all the controls on my forms
and clear them. I have something that sets values to Null and "" but when
users try to save something or close the form they always get warnings about
not having a primary key and telling you that you can't save it, then it
asks you if you want to close it anyways, say yes and all is ok.

Is there a way so that you can go into the form put in some data, clear it
all and then close the form without getting those stupid warnings?? If you
just open the form and close it without touching anything it doesn't give
warnings at all.

TIA,

T.
Hi T. it's likely that the fields causing you grief are
linked fields. The thing to remember is that null is still
a value that you have assigned to a control that can be
stored in a field (if set to accept in table design).

Have you considered using the action me.undo to clear a
new record?

Luck
Jonathan
 
J

Joe Voll

I need to write a script that will go through all the controls on my forms
and clear them. I have something that sets values to Null and "" but when
users try to save something or close the form they always get warnings about
not having a primary key and telling you that you can't save it, then it
asks you if you want to close it anyways, say yes and all is ok.

Is there a way so that you can go into the form put in some data, clear it
all and then close the form without getting those stupid warnings?? If you
just open the form and close it without touching anything it doesn't give
warnings at all.

access automatically generated a primary key value when you enter some data
into a form that is based on a table as long as the primary key is an
autovalue.
if you set up a form that's based on a table and some user enters data and
is afterwards hitting a cancel button he may clear all the data in the new
added dataset but won't delete the dataset itself.
spontaniously there are 2 ways crossing my mind:
1. dont bound the fields in your form to an existing table but include a
"update" button. only if this button is clicked all the data privided in the
form is collected by a vba-sub and stored into a new added dataset
2. control if a new dataset is being created and if the cancel buttons gets
hit, delete the new added record. do this for example by:
form_load: open a new dataset by default and store the new generated ID
value in a variable
cancelButton_onclick: delete the dataset with the current ID (the ID from
form_load)

hope this helps,

Joe.
 
T

T.

Thanks everyone. The "Me.Undo" command is EXACTLY what I needed. As a new
record is opened everytime the form is this works perfectly.

T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top