+ Reply to Thread
Results 1 to 6 of 6

SQL Statement to only pull information based on Text Box from a userform

  1. #1
    Registered User
    Join Date
    02-21-2013
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2007
    Posts
    8

    SQL Statement to only pull information based on Text Box from a userform

    OK,
    I have a spreadsheet that prints receiving labels based on received purchase orders that pulls information from an SQL server. The problem is that it is pulling almost 40,000 lines of data to sort and pull at most 30 lines. One of steps is that the purchase order receipt register has a barcode that is scanned into a text box on a userform. Can I use this information to filter the SQL data pull to only grab that PO number? I'm at a loss on where to begin with this. Below is my SQL statement from the Query builder with an example of a PO number input(PO-rma100613).

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: SQL Statement to only pull information based on Text Box from a userform

    Do you already have code which runs a SQL query, and you want to know how to modify it to use a text box value within the WHERE clause?

    Or are you looking for help building the entire 'connect to db, run SQL query' code?
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: SQL Statement to only pull information based on Text Box from a userform

    Change your SQL to

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    02-21-2013
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: SQL Statement to only pull information based on Text Box from a userform

    I am editing the SQL Command under the query builder. Once the PO number is entered the query will run then recall the results. Based on Mr. Phillips response i'm now at this stage in the command. It isn't giving me errors which is a good step. txt_PO is the name of the text box in the form.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-21-2013
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: SQL Statement to only pull information based on Text Box from a userform

    Ah hah! Got it. I just set up a separate peramenter. It's a work around, but does the job.

    This site shows how to do it
    http://superuser.com/questions/19745...rom-excel-2007

    Please Login or Register  to view this content.

  6. #6
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: SQL Statement to only pull information based on Text Box from a userform

    Quote Originally Posted by welborns2 View Post
    I am editing the SQL Command under the query builder. Once the PO number is entered the query will run then recall the results. Based on Mr. Phillips response i'm now at this stage in the command. It isn't giving me errors which is a good step. txt_PO is the name of the text box in the form.

    Please Login or Register  to view this content.
    That is not how I did it, I concatenated the textbox value into the SQL text.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Pull Information from a query based on parameters
    By ssexton in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-22-2013, 04:10 PM
  2. Macro to Pull information from one Excel Sheet based on information in another sheet
    By IwannabanExcelGod in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-20-2013, 02:11 PM
  3. Pull information in one tab based on field in another tab.. HELP!
    By JanaA in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-08-2008, 11:48 AM
  4. Pull information based on a range of numbers
    By Styckz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-17-2006, 02:15 PM
  5. [SOLVED] Pull information based on a range of numbers
    By Styckz in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 04-17-2006, 03:35 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1