Delete contents of form field upon entry

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to clear the contents of a form field upon entry of that field. I know
I want to use a event procedure and have it execute "on entry", understand
that part. What must I enter into this procedure to get access to clear or
'throw out' what it remembers from the previous entry.

Thanks
 
JR,
I question why your doing this, but...
You would use the OnEnter event to set the value of the field to Null. (must not be a
Required field)

Private Sub YourField_Enter()
YourField = Null
End Sub.

But, if you had navigated to this field using the tab key (the proper way) then the
previous entry value would be highlighted, and just typing the new value would overwrite
the previous entry automatically.
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 
You are correct that the previous contents are slected and typing anything
replaces that entry. My purpose is simply to open that next form with an
empty data entry screen.

I entered the code into a "code" window for the event "on Enter" and saved
changes. However the action remains the same. Upon advancing to teh next
form, the previous entry into the field still remains. What did I most likely
miss in executing this code?

Thanks again
 
JR,
Well, that's a bit different. My code (placed in the form's module) will only clear
the field upon entry into that control.

How is the value being put there on a new record. Is it a Default Value? (either on
the form, or defined in the table)
Is that control bound or unbound to a table field? What is the ControlSource?
If you open a new record and there is a value already in a field, it would most
probably one of the two reasons above.
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 
Thanks Al, here is a run down on what I am doing. I have a simple application
to build and reinforce keyboarding skills. Only table contains words,
phrases, etc. The form displays a word/phrase from the table, a second
unbound text box allows data entry(typing) of teh displayed word. Validation
is set to force the entry to match the displayed item.
After the first correct entry is made, the field entry is left in the data
entry field when the next record is displayed from the table. It would be som
much cleaner if I could have the data entry field appear empty each time a
new record is displayed from the table.
I am sure your code works, I just may not be placing it correctly. I
entered the code into a "code" window for the event "on Enter" and saved
changes. When I go back to the field properties for the unbound object, all I
see in the On Entry event line is [event procedure]. Does this sound correct?
 
JR,
You didn't say whether the text field you want cleared is "unbound" or not. By
Unbound, I mean that the ControlSource is blank, because it is not "bound" to a table
field. For this problem, I will assume it's inbound. An unbound field will show the same
value on all records, until you manually change it, or close the form.

I'd use the OnCurrent event of the form to clear the field. Use your own object and
field names...
Private Sub YourFormNameHere_Current()
YourFieldName = Null
End If

Whenever you browse to another record, SomeField will be cleared.

Yes, I think that perhaps you haven't used module code before (given that you said my
first suggestion "didn't work")
So...
Select the Form, and find the OnCurrent property in the properties dialog box.
Place your cursor in the text box of that property. Using the little arrow on the
right, select EventProcedure.
While keeping the cursor in the textbox, click the little 3 dot (...) button on the
right.
You are now in the code module for the form, and should see...

Private Sub YourFormNameHere_Current()

End If

Type: YourFieldName = Null
in between the lines...

Private Sub YourFormNameHere_Current()
YourFieldName = Null
End If

Whenever you browse to another record, the Current event of the form will "fire",
and SomeField will be cleared.
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."


JR Hester said:
Thanks Al, here is a run down on what I am doing. I have a simple application
to build and reinforce keyboarding skills. Only table contains words,
phrases, etc. The form displays a word/phrase from the table, a second
unbound text box allows data entry(typing) of teh displayed word. Validation
is set to force the entry to match the displayed item.
After the first correct entry is made, the field entry is left in the data
entry field when the next record is displayed from the table. It would be som
much cleaner if I could have the data entry field appear empty each time a
new record is displayed from the table.
I am sure your code works, I just may not be placing it correctly. I
entered the code into a "code" window for the event "on Enter" and saved
changes. When I go back to the field properties for the unbound object, all I
see in the On Entry event line is [event procedure]. Does this sound correct?

Al Campagna said:
JR,
Well, that's a bit different. My code (placed in the form's module) will only clear
the field upon entry into that control.

How is the value being put there on a new record. Is it a Default Value? (either on
the form, or defined in the table)
Is that control bound or unbound to a table field? What is the ControlSource?
If you open a new record and there is a value already in a field, it would most
probably one of the two reasons above.
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 
Thanks for 'sticking' with me on this. I had teh right process, just the
wrong place. I was placing the code in the event properties of the unbound
field, rather than the form. Your mention of 'form in that last explanantion
broke my trance. Works great now, clears the unbound data entry form every
time I advance to a new record.


Thanks again.

Al Campagna said:
JR,
You didn't say whether the text field you want cleared is "unbound" or not. By
Unbound, I mean that the ControlSource is blank, because it is not "bound" to a table
field. For this problem, I will assume it's inbound. An unbound field will show the same
value on all records, until you manually change it, or close the form.

I'd use the OnCurrent event of the form to clear the field. Use your own object and
field names...
Private Sub YourFormNameHere_Current()
YourFieldName = Null
End If

Whenever you browse to another record, SomeField will be cleared.

Yes, I think that perhaps you haven't used module code before (given that you said my
first suggestion "didn't work")
So...
Select the Form, and find the OnCurrent property in the properties dialog box.
Place your cursor in the text box of that property. Using the little arrow on the
right, select EventProcedure.
While keeping the cursor in the textbox, click the little 3 dot (...) button on the
right.
You are now in the code module for the form, and should see...

Private Sub YourFormNameHere_Current()

End If

Type: YourFieldName = Null
in between the lines...

Private Sub YourFormNameHere_Current()
YourFieldName = Null
End If

Whenever you browse to another record, the Current event of the form will "fire",
and SomeField will be cleared.
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."


JR Hester said:
Thanks Al, here is a run down on what I am doing. I have a simple application
to build and reinforce keyboarding skills. Only table contains words,
phrases, etc. The form displays a word/phrase from the table, a second
unbound text box allows data entry(typing) of teh displayed word. Validation
is set to force the entry to match the displayed item.
After the first correct entry is made, the field entry is left in the data
entry field when the next record is displayed from the table. It would be som
much cleaner if I could have the data entry field appear empty each time a
new record is displayed from the table.
I am sure your code works, I just may not be placing it correctly. I
entered the code into a "code" window for the event "on Enter" and saved
changes. When I go back to the field properties for the unbound object, all I
see in the On Entry event line is [event procedure]. Does this sound correct?

Al Campagna said:
JR,
Well, that's a bit different. My code (placed in the form's module) will only clear
the field upon entry into that control.

How is the value being put there on a new record. Is it a Default Value? (either on
the form, or defined in the table)
Is that control bound or unbound to a table field? What is the ControlSource?
If you open a new record and there is a value already in a field, it would most
probably one of the two reasons above.
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."



You are correct that the previous contents are selected and typing anything
replaces that entry. My purpose is simply to open that next form with an
empty data entry screen.

I entered the code into a "code" window for the event "on Enter" and saved
changes. However the action remains the same. Upon advancing to teh next
form, the previous entry into the field still remains. What did I most likely
miss in executing this code?

Thanks again

:

JR,
I question why your doing this, but...
You would use the OnEnter event to set the value of the field to Null. (must not
be
a
Required field)

Private Sub YourField_Enter()
YourField = Null
End Sub.

But, if you had navigated to this field using the tab key (the proper way) then
the
previous entry value would be highlighted, and just typing the new value would
overwrite
the previous entry automatically.
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."

I need to clear the contents of a form field upon entry of that field. I know
I want to use a event procedure and have it execute "on entry", understand
that part. What must I enter into this procedure to get access to clear or
'throw out' what it remembers from the previous entry.

Thanks
 

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

Back
Top