Populated textbox still show old text when text in combobox is deleted (1 Viewer)

dhewwn

Registered User.
Local time
Today, 15:21
Joined
Jan 13, 2019
Messages
13
Hi


I tried to populate textbox from combobox and it works. When deleting text in the combobox, the populated textbox will return to null..
Now when i tried to add a new combobox and textbox, the textbox does filter based on the combobox. But the textbox still show the last populated text when the value in the combobox is deleted.
Why is it so?
I tried to recreate the whole form, its old value is still there when it didnt before.

I use 'on change' on the combobox.
me.txt_Text1 = me.cbo_Combo1.Column(2)
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:21
Joined
Oct 29, 2018
Messages
21,358
That looks like it should work. Are there any other code involved? Are you getting any errors?
 

dhewwn

Registered User.
Local time
Today, 15:21
Joined
Jan 13, 2019
Messages
13
its the same thing? because when i google, they only show put in on change event.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:21
Joined
Oct 29, 2018
Messages
21,358
its the same thing? because when i google, they only show put in on change event.
So, how exactly are you deleting the content of the combobox?
 

dhewwn

Registered User.
Local time
Today, 15:21
Joined
Jan 13, 2019
Messages
13
That looks like it should work. Are there any other code involved? Are you getting any errors?


Yeah, there's a filter code for the subform. But its in the after update event.
Which I also did before, and it works alright. Just suddenly the value in the textbox doesnt clear itself. This is a new textbox and combobox that i added in the form, just to clarify. The old one works perfectly.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:21
Joined
Oct 29, 2018
Messages
21,358
Yeah, there's a filter code for the subform. But its in the after update event.
Which I also did before, and it works alright. Just suddenly the value in the textbox doesnt clear itself.
Can you post a demo version of your db?
 

dhewwn

Registered User.
Local time
Today, 15:21
Joined
Jan 13, 2019
Messages
13
Sure just let me remove condential info
 

dhewwn

Registered User.
Local time
Today, 15:21
Joined
Jan 13, 2019
Messages
13
Its in fom_TaxInv.
The correct one is Client Name combobox.
The address and the rest is its populated textbox.


The one with the error is cmb_InvNo.
The populated textbox is Text55.
 

Attachments

  • AR v11 - Copy (2).zip
    286.2 KB · Views: 39
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 00:21
Joined
Oct 29, 2018
Messages
21,358
Its in fom_TaxInv.
The correct one is Client Name combobox.
The address and the rest is its populated textbox.


The one with the error is cmb_InvNo.
The populated textbox is Text55.
Hi. Thanks. I'm looking at it now and can see what you mean. I'll let you know if I find out why it's happening. Otherwise, we might just devise a workaround for you.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:21
Joined
Oct 29, 2018
Messages
21,358
Hi. Thanks. I'm looking at it now and can see what you mean. I'll let you know if I find out why it's happening. Otherwise, we might just devise a workaround for you.
Okay, this is very interesting. The only thing I could think of is maybe the control is corrupted. However, I was able to see the same behavior in the working combobox, once in a while. Most of the time, it works fine. But the new combobox, it doesn't work the same, most of the time (it's the opposite).

So, the only workaround I could think of is to use the AfterUpdate event of the combo to clear out the textbox is the combo is empty. Other than that, the filtering of the form is not affected, so even if the textbox is left with something showing in it, the subform data is still correct.
 

Solo712

Registered User.
Local time
Today, 03:21
Joined
Oct 19, 2012
Messages
828
Its in fom_TaxInv.
The correct one is Client Name combobox.
The address and the rest is its populated textbox.


The one with the error is cmb_InvNo.
The populated textbox is Text55.

You need to requery the combo box from fom_ClientDetails when saving the new client record. Add the following in red in the Click_Save sub:
Code:
Else
DoCmd.RunCommand acCmdSaveRecord
[COLOR="Red"]If CurrentProject.AllForms("fom_TaxInv").IsLoaded = True Then
       Forms!fom_TaxInv!cmb_ClientName.Requery
End If[/COLOR]
End If

Best,
Jiri
 
Last edited:

dhewwn

Registered User.
Local time
Today, 15:21
Joined
Jan 13, 2019
Messages
13
You need to requery the combo box from fom_ClientDetails when saving the new client record. Add the following in red in the Click_Save sub:
Code:
Else
DoCmd.RunCommand acCmdSaveRecord
[COLOR=Red]If CurrentProject.AllForms("fom_TaxInv").IsLoaded = True Then
       Forms!fom_TaxInv!cmb_ClientName.Requery
End If[/COLOR]
End If
Best,
Jiri


Nope, its still the same.
 

dhewwn

Registered User.
Local time
Today, 15:21
Joined
Jan 13, 2019
Messages
13
Okay, this is very interesting. The only thing I could think of is maybe the control is corrupted. However, I was able to see the same behavior in the working combobox, once in a while. Most of the time, it works fine. But the new combobox, it doesn't work the same, most of the time (it's the opposite).

So, the only workaround I could think of is to use the AfterUpdate event of the combo to clear out the textbox is the combo is empty. Other than that, the filtering of the form is not affected, so even if the textbox is left with something showing in it, the subform data is still correct.


How do i type out the code? So there is no way to solve the root, only a workaround?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:21
Joined
Oct 29, 2018
Messages
21,358
How do i type out the code? So there is no way to solve the root, only a workaround?
Well, if it's a corrupted form or control, part of the solution is to do a C&R or replace the corrupted form or control with a new one. For the workaround, in the AfterUpdate event, you could check if the combo is empty. And if it is, empty the textbox as well. For example:
Code:
If IsNull(Me.ComboName) Then Me.TextboxName=Null
 
Last edited:

dhewwn

Registered User.
Local time
Today, 15:21
Joined
Jan 13, 2019
Messages
13
ok, i will try to redo the form and see if it works. If not, I guess I will just use the empty code.
Thank you.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:21
Joined
Oct 29, 2018
Messages
21,358
ok, i will try to redo the form and see if it works. If not, I guess I will just use the empty code.
Thank you.
You're welcome. Good luck. If I run into a better solution, I'll let you know.
 

Users who are viewing this thread

Top Bottom