Clear Form

G

Guest

im trying to clear multple text fields in a form with a button. the form
itself refrences a table with various % information. the user than has to
enter the stats for a specific item, and the form than does some calculations
based on the stsats and the %. however, when the user wishs to figure
calculations for another item using a drop-down box for item selection, all
of the entries made my the user in the text boxes remain.

is there a way to clear all the text boxes that do not pull info from the
table? basically i want a button that will clear the form of all of the user
entered information
 
S

Squirrel

Hi,

You state you have textboxes accepting data from the user and also text
boxes pulling info
from the table so I don't see a generic method for clearing them all.
Therefore something like
this might be the solution. Have your command button call a subroutine like
this - obviously
using the names of the textboxes you want to clear:

private sub ClearTextboxes()
me!txtbox1 = NULL
me!txtbox2 = NULL
me!txtbox3 = NULL
me!txtbox4 = NULL
end sub

HTH -Linda
 
G

Guest

hmmm.. ok.. well.. is there a simple way to reset the textboxs to their
DefaultValue? the information coming from an existing table isnt being
modified at all... they are chosing a record to view from a combo box.
idealy since its possible for some of items to have multiple stats, reseting
the form specific textboxes to their default value when the user either
clicks the button, or selects a diffrent item would be perfect.

also, i hate to admit it.. but i havent done any code in over 8 years... so
my brain is telling me its possible to do this stuff, but it doesnt remember
how. the form it self if titled Food... and the button is titled reset.. and
the textboxes are titled rsrc1fill1, rsrc2fill1, rscrc3fill1, etc... in the
onClick section i have created an event procedure...
Private Sub Reset_Click()
Food!rsrc1Fill1 = Null
Food!rsrc2Fill1 = Null
Food!rsrc3Fill1 = Null
Food!rsrc4Fill1 = Null
End Sub

am i on the right track here? thanx in advance for you patience and time
 
J

John Spencer (MVP)

pardon me for jumping in.

Assuming that your controls have default values, you should be able to use the
following code to re-assign that to the controls

Private Sub Reset_Click()
Me.rsrc1Fill1 = Me.rsrc1Fill1.DefaultValue
Me.rsrc2Fill1 = Me.rsrc1Fill2.DefaultValue
Me.rsrc3Fill1 = Me.rsrc1Fill3.DefaultValue
Me.rsrc4Fill1 = Me.rsrc1Fill4.DefaultValue
End Sub
 

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