Dim LSQL as string
LSQL = "select * from Suppliers where Supplier_ID = " & txtSupplier_ID
The result set will return all records from the Suppliers table where the Supplier_ID equals the value that is found in the textbox control called txtSupplier_ID.
Our next example will look at a control whose value contains a string. The following code uses a control called txtSupplier_City in an SQL statement in VBA code.
Dim LSQL as string
LSQL = "select * from Suppliers where Supplier_City =' " & txtSupplier_City & "'"
You will notice in this example that you need to place a single quote in front of the control (txtSupplier_City) as well as one after. This is because string values must always be surrounded by single quotes in an SQL statement
This result set will return all records from the Suppliers table where the Supplier_City equals the value that is found in the textbox called txtSupplier_City.