UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Odd Textbox Issue, Access 2016    
 
   
dg_moore
post Sep 15 2019, 06:01 PM
Post#1



Posts: 335
Joined: 22-April 11



I hae a form with two combo boxes: TripLeader and TripCoLeader. In order for a user to be able to clear these fields for whatever reason they may want, I have an adjacent text box Clear with code

CODE
Private Sub Label108_Click()

Me.TripCoLeader = Null
Me.TripCoLeader.Requery

End Sub

Private Sub Label109_Click()

Me.TripLeader = Null
Me.TripLeader.Requery

End Sub


The first procedure works correctly, but in the second I get "Method or Data Member not found", with .Requery highlighted. For the other text box, the code editor displays the full range of methods available, including Requery. For the problem text box, the code editor displays .Value as the only available option, so for some reason it apparently does not recognize the text box as an object for which any methods are available. I have compacted/repaired and decompiled/compiled the app, and have also deleted the control and replaced it with a new one but the behavior does not change. I want the requery to refresh the combo box so it does not to continue to display a value after the code runs. If I comment out the .Requery and run the code, the combo box continues to display the original value, but if I step off the record and return to it the box is empty. So I can set it to null, but can't refresh it.

Any suggestions?

Go to the top of the page
 
DanielPineault
post Sep 15 2019, 06:17 PM
Post#2


UtterAccess VIP
Posts: 6,901
Joined: 30-June 11



You shouldn't need a requery.

Any chance you can post a sample of the db/form in question.

Have you tried deleting the control and recreating? Just saw that detailed in your original post.
You've validated the control's name? (I'm assuming you have, but just had to ask)
Why not use a command button for such actions?
Any differences between the combo boxes? bound vs unbound? Any other events that could be interfering?

--------------------
Daniel Pineault (2010-2019 Microsoft MVP, UA VIP, EE Distinguished Expert 2018)
Professional Help: https://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: https://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...(you are responsible for your choices and actions)
Go to the top of the page
 
June7
post Sep 15 2019, 06:44 PM
Post#3



Posts: 881
Joined: 25-January 16



You first say these are comboboxes then further in narrative you refer to textboxes. Which is correct?

If these are bound controls, then clearing them would remove data from record. Is that what you want to allow?

Is this form in Datasheet view and that is why you use a textbox for 'Clear' action?

Why is code in Click event of two controls with Label in name? Labels have neither events nor Value.

Requery just refreshes combobox or listbox list, it does not change value already in field of bound control.



This post has been edited by June7: Sep 15 2019, 06:56 PM

--------------------
Attachments Manager is below the edit post window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG! http://www.cpearson.com/Excel/DebuggingVBA.aspx
Go to the top of the page
 
dg_moore
post Sep 16 2019, 06:59 AM
Post#4



Posts: 335
Joined: 22-April 11



Unfortunately my explanation of the issue was confusing and not entirely accurate. The two controls TripLeader and TripCoLeader are combo boxes. The two objects I referred to as TextBoxes are actually Labels with caption "Clear". OnClick of the labels runs the code to set the corresponding combo box to Null.

I elected to use the label with the underlined "Clear" because the form is crowded and already has too many control buttons; the "Clear" link looks better - the cursor turns to the "hand" icon, and the link takes up less space than a button would.

One of the two combo boxes, which are otherwise identical, but bound to different table fields, throws the error "Method or Data Member not found" when the code tries to requery if. The field actually does get set to null, but the control continues to display its original value until I step off the record and then return to it. The other combo box requeries correctly, with no error. This is the issue I'm trying to figure out. It's confusing for a user when he/she clicks "Clear" but the field continues to display its value.

I have been able to work around the problem by issuing MoveNext and MovePrevious after setting the field to null. It's not elegant, but it successfully clears the combo box.
This post has been edited by dg_moore: Sep 16 2019, 07:03 AM
Go to the top of the page
 
missinglinq
post Sep 16 2019, 07:11 AM
Post#5



Posts: 4,637
Joined: 11-November 02



QUOTE (June7)
Labels have neither events nor Value.


Actually, Labels attached to Controls have no events...but independent Labels (those created by the developer) do have a limited set of events...such as OnClick.

I agree that the scenario presented is more than a little confusing. If this were a Dataset View Form, rather than have a separate Textbox to do this with...I'd simply use the DoubleClick event of the Combobox itself to clear it.

And, as Daniel said, you don't need the Requery to do this.

Linq ;0)>

--------------------
Hope this helps!

The problem with making anything foolproof...is that fools are so darn ingenious!

All posts/responses based on Access 2003/2007
Go to the top of the page
 
BruceM
post Sep 16 2019, 07:24 AM
Post#6


UtterAccess VIP
Posts: 7,971
Joined: 24-May 10
From: Downeast Maine


If the control and the field have the same name I would try renaming the control. At least you would be clear about what was not found.

Me.Refresh may be what you need instead of requery.
Go to the top of the page
 
dg_moore
post Sep 16 2019, 08:30 AM
Post#7



Posts: 335
Joined: 22-April 11



I tried that, with the same result. For some reason, Access thinks this combo box is not a control with methods. In the code editor, when you enter "Me.cbo_TripLeader. " the only option that pops up is ".Value" For the other combo box the editor pops up the full list of combo box methods. I deleted the original combo box and recreated a new one from scratch, but the result were the same.

Anyway, my workaround is ok, so I'll move on to other issues. Thanks.
Go to the top of the page
 
DanielPineault
post Sep 16 2019, 08:40 AM
Post#8


UtterAccess VIP
Posts: 6,901
Joined: 30-June 11



Have you tried renaming the combo box?

--------------------
Daniel Pineault (2010-2019 Microsoft MVP, UA VIP, EE Distinguished Expert 2018)
Professional Help: https://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: https://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...(you are responsible for your choices and actions)
Go to the top of the page
 
June7
post Sep 16 2019, 12:26 PM
Post#9



Posts: 881
Joined: 25-January 16



Thanks, Linq. Yes, I forgot unassociated labels do have some events.

dg, if you want to provide db for analysis, follow instructions at bottom of my post.


--------------------
Attachments Manager is below the edit post window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG! http://www.cpearson.com/Excel/DebuggingVBA.aspx
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    20th October 2019 - 01:36 AM