Page 2 of 2 FirstFirst 12
Results 11 to 11 of 11

Thread: How do I use a value from the current form in my SQL Statement?

  1. #11
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    a) Take a look at demo app "example_dynamicautosuggest"
    If you start typing Last Name, the autosuggestion from sql-statement fires as you type letter by letter
    and dropdown list is shown dynamically using SQL:

    Code:
    proc page1_section1_field3_interactivechange()
        m_field = Lianja.get("page1.section1.field3")
        if len(m_field.value)!=0
            m_sql = "select last_name from example where last_name like '" + m_field.value + "%'"
        else
            m_sql = ""
        endif
        m_field.autosuggest = m_sql
    endproc
    In this case formfield is used as a "standalone"
    If you are not testing len(m_field.value), you could write:
    Code:
    m_sql = "select last_name from example where last_name like '" + Lianja.get("page1.section1.field3").value + "%'"
    In your case:
    Code:
    m_sql = "SELECT firstname FROM userlookup WHERE userid =  '"+Lianja.get("page1.section1.useridontheform").value+"'"


    Note that we build the string.

    b) If your form is database binded (see demo app "example_virtualtables")
    you should use macro with table/column name like that in "SQL statement" attribute of section2

    select * from orders where customerid='{vcust.customerid}'
    Child Section2 (grid) is populated indirectly with data from the parent Section1's formfield page1.section.field1,
    in fact from underlying table vcust and column customerid.

    In your case:
    SELECT firstname FROM userlookup WHERE userid = '{yourtable.column_under_useridontheform}'


    Note that we write into section's attribute.
    Last edited by josipradnik; 2018-10-15 at 13:39.

Tags for this Thread

Bookmarks

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
  •  
Journey into the Cloud
Join us