Clear text field and db entry

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

Guest

Hello,

I have a checkbox that when checked makes a textbox visible, and when not
checked, or unchecked, leaves/makes it invisible.
People are expected to check the box and then enter text, and on
AfterUpdate, the content of the checkbox is used to update the form's
underlying query.

When the texbox is hidden again by unchecking the checkbox, I would like to
remove the data that was stored in there.
I can use txtbox.Value = Null to clear the text box, but the data in the
query isn't touched by this, or if it is, the change is not saved.

What is a good way to delete that information from the db?

Thank you.
 
one method to clear the value from the query you can close and reopen the
query in the background....
 
How do you do that?
I've experimented with an update query, and that seems to work, except I get
a write conflict when I click on a checkbox on another subform right
afterwards.
 
Is there a reason why you are not using a bound form? If it was bound
to your query, any updates to the textbox (including setting it to
Null) would be updated in the query automatically.

Hello,

I have a checkbox that when checked makes a textbox visible, and when not
checked, or unchecked, leaves/makes it invisible.
People are expected to check the box and then enter text, and on
AfterUpdate, the content of the checkbox is used to update the form's
underlying query.

When the texbox is hidden again by unchecking the checkbox, I would like to
remove the data that was stored in there.
I can use txtbox.Value = Null to clear the text box, but the data in the
query isn't touched by this, or if it is, the change is not saved.

What is a good way to delete that information from the db?

Thank you.
Armen Stein
Microsoft Access MVP
www.JStreetTech.com
 
Yes, there is a reason.
The checkbox is on a continuous subform, and the textbox is on the parent
form.
Both are based on different tables.
 
in general terms; when you refresh the text box...(i.e. make it invisible
again and change back to null)...this would seem like the right point to
close that query too...

I presume your existing method to open/run of the query will remain
effective....
 
Ok, I've taken your advice and modified it a bit - since I lack the knowledge
to bind my textbox directly to the other table, I put a small hidden textbox
on the continuous subform that IS bound to the corresponding text field in
the query, so when the checkbox is unchecked and the textbox on the parent
form is hidden, the content of the hidden textbox is also set to Null, and
that does clear out the table.
The one potential problem is that the changes don't seem to get written to
the query immediately. When I go to another record they are, but when I move
around the same record, I can't identify reliably what else causes the
changes to be committed to table. Sometimes going to another tab does it,
sometimes it doesn't.

But anyway, thank you very much for providing the inspiration.
 
The one potential problem is that the changes don't seem to get written to
the query immediately. When I go to another record they are, but when I move
around the same record, I can't identify reliably what else causes the
changes to be committed to table. Sometimes going to another tab does it,
sometimes it doesn't.

Access will commit the changes to the table when you navigate to a
different record, or when you switch between forms (inc. main &
subforms.) So if you click on another tab that contains a different
form, the changes will be committed, but if it is just another tab of
the same form, they won't. I hope that is clearer than it sounds. :)
 

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