cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Pieter_NL
Frequent Visitor

Retrieve a record from SQL source to a form with a button outside the form.

Hi all,

 

I'm new to powerapps, I have experience in regular programming so it's kinda frustrating to trying to figure out how to do something really basic. 

 

I have a form that's linked to a SQL table. But I want to retrieve a record based on a ID I enter in a textfield outside the form, after I click a button.


See attached image for reference.

 

Anyone can point me in the right direction?

 

Thanks in advance!

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Pieter_NL 

The form has a property called Item. This defines the record that the form displays.

If you want the form to display the record that matches the ID that a user enters into a text input control, you would set the Item property to the following:

LookUp('[dbo].[SQLTable]', IDField=txtIDField.Text)

If your SQL ID field is numeric, you'll need to convert the text input to a value.

LookUp('[dbo].[SQLTable]', IDField=Value(txtIDField.Text))

This technique will work without a button. If you need to use a button, you would set the OnSelect property of the button to store the text input control value into a variable by calling the Set function. You would then modify the LookUp function to reference the variable, rather than the text input control.

View solution in original post

5 REPLIES 5
eka24
Super User
Super User

I will recommend you insert a Gallery and Put the TableName in the Items Property.

Then on the Items Property of the Form put: Gallery1.Selected.

 

Thus whatever you select in the Gallery including the number will be populated on the form.

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Pieter_NL
Frequent Visitor

Thanks I tried that, but I do not like a gallery because the table can have hundreds of records. 

 

Users know the ID, because it's on a barcode. So they scan the barcode to enter the ID in the field, and then it should retrieve the record. 

Hi @Pieter_NL 

The form has a property called Item. This defines the record that the form displays.

If you want the form to display the record that matches the ID that a user enters into a text input control, you would set the Item property to the following:

LookUp('[dbo].[SQLTable]', IDField=txtIDField.Text)

If your SQL ID field is numeric, you'll need to convert the text input to a value.

LookUp('[dbo].[SQLTable]', IDField=Value(txtIDField.Text))

This technique will work without a button. If you need to use a button, you would set the OnSelect property of the button to store the text input control value into a variable by calling the Set function. You would then modify the LookUp function to reference the variable, rather than the text input control.

View solution in original post

Pieter_NL
Frequent Visitor

Thank you @timl  That works 🙂

 

Now I need to create a record when the lookup doesn't find a record. I'll try to figure that out myself first 🙂

 

Is there a syntax dictionary for Powerapps? Where I can just browse all functions and formula's and see for myself if I can use them?

You're welcome @Pieter_NL! I'm glad that works for you.

Here's a link to the formula reference.

https://docs.microsoft.com/en-gb/powerapps/maker/canvas-apps/formula-reference 

Feel free to post back if you need any more help.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,068)