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 / Entering Multiple List...
Power Apps
Answered

Entering Multiple Listbox Values w/ Text Box Value One At A Time to SQL

(0) ShareShare
ReportReport
Posted on by 36

Hi All,

 

  So the gist of what I am trying to do here is get multiple values to be recorded in SQL as individual records.  I am working with a table called dbo.personfood which is linked to the dbo.person table by the personid.  What I am trying to do is enter the personid into a textbox and then select the different food items from a listbox but have them enter as individual records.  This post got me going in the right direction, https://powerusers.microsoft.com/t5/PowerApps-Forum/Passing-Multiple-Values-from-Listbox-one-at-a-time-to-SQL/m-p/56976#M23557, but didn't completely solve my problem.

 

  An example of what I am trying to do is if the user enters 11 for the personid in the textbox and then select chocolate, bread, and milk from the listbox the data will enter into the personfood table as:

personid     fooditem

11                chocolate

11                bread

11                milk

 

  Is there any way to do this?  I know the forall statement can be used with listboxes to have each value get its own row in a SQL table but can this be used in combination with a textbox?

 

Categories:
  • Verified answer
    v-micsh-msft Profile Picture
    Microsoft Employee on at

    Hi @dhofknecht,

     

    Yes, that could be done with the formula I shared in the previous thread, assuming you have the personId field defined in your SQL table.

    Then the formula would be changed as below:

    ForAll(ListBox1.SelectedItems.Value,
    Patch('[dbo].[Foods]',
    Defaults('[dbo].[Foods]'),
    {foodName:Value,
    personid:value(TextInput1.text)}
    )
    )

    Take a try with the formula above.

    Regards,

    Michael

  • dhofknecht Profile Picture
    36 on at

    This worked perfectly for what I was trying to do!

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 409 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 252 Most Valuable Professional

Last 30 days Overall leaderboard