After update event

captainlove

captainlove
Local time
Today, 14:33
Joined
Apr 18, 2008
Messages
39
I have a main form with a combo box, containing a list of qcps(numeric values)

on that main form is a text box to add to my subform data like references or responsibilities for each qcp i.e 10000

The problem is that when I add data to the text box and I click accept, which insert the value into a table. The data in the text box still stay.

My question is, what code do I put in the afterupdate event of the mainform to clear text after hitting the accept button to accept the data

Below is an example of my accept code and delete code on the form

delete code
-------
Sql = "Delete from tblresponsibilities where resp_id =" & Me.ID

DoCmd.RunSQL Sql

Accept code

-----------
Sql = "INSERT INTO tblResponsibilities(responsibilities,qcpID) VALUES ('" & Me.txtresponsibilities & "','" & _
Me.txtQcp & "' )"
DoCmd.RunSQL Sql


so I guess I need the after update code.



Can anyone help
 
This code makes the data in the subform null as well as making the textbox blank. How can I make only the textbox blank after update
 
In the _Current() event

Me.txtresponsibilities.Value = ""
 
The problem with that code is that A textbox control does not have a current event
 
Another thing is that, when I use these two codes in the lost focus event of the textbox control, it insert a blank row in my subform
Me.txtresponsibilities.Text = ""
Me.txtresponsibilities.Value = ""
 
Another thing is that, when I use these two codes in the lost focus event of the textbox control, it insert a blank row in my subform
Me.txtresponsibilities.Text = ""
Me.txtresponsibilities.Value = ""

If the text box is bound to a field then that would occur. If they are unbound controls then it shouldn't do a thing.

And, by the way the CURRENT event is a FORM level event, not a control level event, but it fires when you move from record to record.
 
Hello Bob

My textbox is unbound, using either of those still inserts blank rows into the subform
 
The problem with that code is that A textbox control does not have a current event

Exactly. That is why it should be Form_Current(). But was using shorthand - my bad. :rolleyes:
 
Hello Bob

My textbox is unbound, using either of those still inserts blank rows into the subform

I'm wondering if you are really getting a blank row or if it is just the subform showing the "new record" where you can start a new record. If you temporarily set the subform's AllowAdditions property to No I think you may see that they go away because it really isn't a new record as such, just a placeholder. And, if it is an actual new record then you probably have something else going on and it would be time to post your db so we can find it.
 

Users who are viewing this thread

Back
Top Bottom