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

Announcements

News and Announcements icon
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,066

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:
  • 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,066 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 397 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 354

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard