This topic is locked

SQL Variables

2/27/2019 4:01:04 PM
ASPRunnerPro General questions
J
Jkelleyus author

If I need more flexibility in a lookup dropdown, I'd like to use a form variable in my lookup query.
Say I have a dropdown called PartNumber, and I want to use the selected field in a subsequent dropdown that will require a table join.
The query would look something like this:
SELECT pro2.Mold_Center

FROM dbo.production_partmaster pro

LEFT OUTER JOIN dbo.production_moldtypes pro1 ON pro.moldtype=pro1.id

LEFT OUTER JOIN dbo.production_moldcenter pro2 ON pro1.id=pro2.MoldType

WHERE pro.partno = <selected previous dropdown PartNumber>.
How do I get the <selected previous dropdown PartNumber> from the form?
Any help is appreciated!!
Thanks,
John

admin 3/2/2019

If PartNumber is a numeric field it will be something like this:

SELECT pro2.Mold_Center

FROM dbo.production_partmaster pro

LEFT OUTER JOIN dbo.production_moldtypes pro1 ON pro.moldtype=pro1.id

LEFT OUTER JOIN dbo.production_moldcenter pro2 ON pro1.id=pro2.MoldType

WHERE pro.partno = :PartNumber


If PartNumber is a text field it will be something like this:

SELECT pro2.Mold_Center

FROM dbo.production_partmaster pro

LEFT OUTER JOIN dbo.production_moldtypes pro1 ON pro.moldtype=pro1.id

LEFT OUTER JOIN dbo.production_moldcenter pro2 ON pro1.id=pro2.MoldType

WHERE pro.partno = ':PartNumber'


More info:

https://xlinesoft.com/asprunnerpro/docs/sqlvariables.htm