How to access text property of a textbox? (1 Viewer)

KitaYama

Active member
Local time
Today, 16:06
Joined
Jan 6, 2022
Messages
442
I'm trying to check if a user has typed a + sign in an unbound multi line text box or not. If yes, I will run a function to do some specific actions.
I've tested with OnKeyDown, OnKeyUp & OnChange events. And receive the same error message in each case.
Access keeps telling me (if I understand well) that for accessing text property, the control should have the focus.

If I'm typing in a textbox, it means the textbox has the focus. Why Access keeps throwing the same Error over and over.
To narrow down what is causing the error, I deleted everything and added just two lines. (following image).

Still the same :

2022-03-05_09-08-46.png


To check if the control has the focus, I added the first line. Immediate window tells me the focus is on the same textbox.

1- I've decompiled/Recompiled several times.
2- I've compact & repaired.
3- I've replaced the line in problem with Screen.ActiveControl.text and still receive the same error message.
4- If I copy and paste the same textbox to another form or another database, the code runs successfully. No error message.

What are my options?
Thanks for your time, help and any kind of advice.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:06
Joined
May 7, 2009
Messages
16,408
I see you've set AllowAdditon to yes and then have hide all the textboxes.
I think I can use that.
yes i am toggling it.
When there is No Record, Allow Additions = Yes., but Hide all textbox (controls).
When there is 1 or more records, Allow Additions = No, show all textbox.
This will eliminate the Error, when you try to get the .Text of the textbox.

As I said the Error occurs When there is no record and Allow Additions is Set to No.
 

KitaYama

Active member
Local time
Today, 16:06
Joined
Jan 6, 2022
Messages
442
@MajP
thanks for your help.
I'm checking your sample databases in #4, but it seems there's no sub form in the main form. maybe it's because of this damn remote desktop app.
But I can understand the concept you explained.
I'll try it when I'm back in office.

Again thanks
 

KitaYama

Active member
Local time
Today, 16:06
Joined
Jan 6, 2022
Messages
442
tell me, upon seeing there is a "+" sign on the .Text, what next is the pseudocode to do?
then i will make a Real working example (not the search form, but on post#7 you said it is a search form?)
I really appreciate your offer. But I think I can manage that as far as I can read .text property without error.

If you're curious :
The textbox is multi line. Users can type
A
F
G
and filter the form. They receive the result for : Field=A Or Field=F Or Filed=G

Now I'm adding a new feature to search. If the user type :
A+C
H
V+Z

the result would be : Field Between (A & C) OR Field=H Or Field Between (V & Z)

Of Course this is a single letter. In fact there are 8 different search fields for searching different fields with different data types

As I explained I can manage the search. I had problem with the error message. And for now it seems that's OK.

million thanks again...
 
Last edited:

MajP

You've got your good things, and you've got mine.
Local time
Today, 03:06
Joined
May 21, 2018
Messages
6,371
there is no "subform" on your demo?
and the recordsource is Not a Blank recordset
Thanks that was the wrong file. In the version without the subform type in something that returns no records like "zz". This will throw the error. Then you can do the same in the form with the subform and not get the error.
 

Attachments

  • FocusDemo.accdb
    876 KB · Views: 27

Users who are viewing this thread

Top Bottom