Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I reset a field in access form 2

Status
Not open for further replies.

aaabuhalime

Instructor
Nov 22, 2012
67
0
0
US
Hi All,
I want to ask how can I reset a field in access form , I have created a bound form,I have afield that I want to reset every time I open the form , that form hold few values, when I close the form and reopen it I still see the value of the field as is (the value of my last selection),I think this because it is a bound form even if I don't save the form, how can I fix this, when I open the form I want to see this field blank. I used the following code
vb said:
Who.DefaultValue = """" & Who & """"
under after update of that field but, it gives me what I want, but what I ever I select doesn't appear or go to the table.

Any help will be appreciated.
 
I'm not sure anyone understands your question or requirements. Forms don't hold values. Tables hold values in fields. Values from fields are displayed in controls on forms and reports. Saving a form won't save default values unless the form is in design view.

A default value only sets the values of any new records added to the form's record source. What is "Who" in your quote/code?

Please help us out with a few more details.

Duane
Hook'D on Access
MS Access MVP
 
Dear Duane,
Thank you for your reply, I am sorry for not being more detailed, I have created abound form, I have a field called "Who"in the form, the Who field (combo box)holds the following values "Teacher, Student, Principle", when I open the form and selects "Student " for example, when I close the form and reopen it I still see the value "student" in that the field (the value of my last selection),I think this because it is a bound form even if I don't save the form, how can I fix this, when I open the form I want to see this field blank. I used the following code


vb said:
Who.DefaultValue = """" & Who & """"

under after update of that field, it gives me what I want, but what I ever I select doesn't appear or go to the table remains blank in the table.

Again what I want is when I select the value for the "who" field if i close the form then reopen it I want to the this field to be blank, I hope it is clear and more detailed this time :)
Any help will be appreciated.

Many thanks in advance.
 
If you want this Control to be blank, each time you open the Form, it has to be Unbound! The rest of the Form can be Bound, but not this Control!



The Missinglinq

Richmond, Virginia

The Devil's in the Details!
 
I don't think the control has to be unbound. It can't contain an expression beginning with "=". If the control source is a field name, the value from the record will be displayed. You could have code to set the value to Null but I'm not sure why you would want to change the value of field every time you open the form.

Duane
Hook'D on Access
MS Access MVP
 
I want the user when ever they open the form to see it blank, because what happens if they forget to change the selection, the selection from a previous entry will remain there it will mess the record.
 
I agree with dhookom, the control has to be bound, because if I unbound the control I get an error.
 
Dear dhookm,
Thanks for asking, here is the scenario, when I open a blank form, if I select Student, then close the form and reopen it again I still see "Student in that field, what I want is every time when I open the form for new entry I want the field "Who" to be blank . I hope it is clear .

thanks
 
When you "reopen it again", aren't you looking at an existing record in your form's record source? Apparently this record has a value in the field that you are seeing.

What is the control source of the combo box? Is the form bound to a record source?

Duane
Hook'D on Access
MS Access MVP
 
I want the field "Who" to be blank
Set it to Null in the Load event procedure.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
When you "reopen it again", aren't you looking at an existing record in your form's record source? No
Apparently this record has a value in the field that you are seeing.Yes the value I selected.

What is the control source of the combo box? contro source of that combobox is "Who" filed in that table
Is the form bound to a record source? yes this I mentiond in the earlier posts.

Please let me know if you have any other questions.
 
If you want to change the value of the Who field in the first record that displays when your form opens, then use PH's suggestion. I don't understand why you wouldn't be looking at an existing record unless you are opening the form in Add Mode or the Data Entry property of the form was "Yes".

Code:
Private Sub Form_Load()
    Me.Who = Null
End Sub

Duane
Hook'D on Access
MS Access MVP
 
In fact I suggested this:
Code:
Private Sub Form_Load()
  If Me.NewRecord Then
    Me!Who = Null
  End If
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top