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 / 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:
I have the same question (0)
  • Verified answer
    v-micsh-msft Profile Picture
    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

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 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard