web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to empty a variabl...
Power Apps
Answered

How to empty a variable when a user deletes the text in a textbox ?

(0) ShareShare
ReportReport
Posted on by 1,042

Dear community,

 

I have a Textbox for searching in a gallery and a search icon and a cancel icon.

The OnSelect of the cancel icon is set to: Set(searchQuery;"")&& Reset(TextBox1)

Now i need code for clearing the gallery when the user deletes the text in the textbox;

 

I have tried it myself to empty the variable when the textbox is empty in the OnChange of the textbox. but no luck:

 

If(
Len(TextBox1.Value) = 0;
searchQuery;""
)

 

This is the code of the gallery:

 

If(
Len(searchQuery) > 0;
Search(
dbEmployeeDirectory;
searchQuery;
"crcfa_voornaam"
)
)

 

Gr. Peter

 

Categories:
I have the same question (0)
  • cha_cha Profile Picture
    4,932 Moderator on at

    Hello @PeKi72 

     

    Try this:

    If(
     Len(searchQuery) > 0;
     Search(
     dbEmployeeDirectory;
     searchQuery;
     "crcfa_voornaam"
     );
     Blank()
    )
  • CU16021406-1 Profile Picture
    1,042 on at

    When i enter a search-criteria in the textbox records are shown. When i delete the text the records are still being displayed in the gallery. The code doesn't work.

  • Verified answer
    cha_cha Profile Picture
    4,932 Moderator on at

    Hello @PeKi72 

     

    How about this:

    If(
     IsBlank(TextBox1.Text);
     Blank();
     Search(
     dbEmployeeDirectory;
     TextBox1.Text;
     "crcfa_voornaam"
     )
    )
    

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard