VBA access 2007 recordset
-
Dear all, am doing the follows: Public Function totalsumbycontract(a As String, b As Integer) As Double Set classdb1 = CurrentDb() set classrecset1 = classdb1.OpenRecordset("select unit_price from contract_details where contract_number = ' " & a & " ' ") end function where a is the contract number, and b is contract id. the problem is when am runnig the query by using contract number, it returns 0 records, while by contract id , it works fine. Contract number is defined in table desig as TEXT, and id is defined as number. also if i run the query on the table it self by contract_number , it works fine. only when am using the query in this code , its not working. Dunno wahts the mistake i did?? and have no clue ?? its just a simple line of code :~ Can any body guide ??
0 will always beats the 1.
-
Dear all, am doing the follows: Public Function totalsumbycontract(a As String, b As Integer) As Double Set classdb1 = CurrentDb() set classrecset1 = classdb1.OpenRecordset("select unit_price from contract_details where contract_number = ' " & a & " ' ") end function where a is the contract number, and b is contract id. the problem is when am runnig the query by using contract number, it returns 0 records, while by contract id , it works fine. Contract number is defined in table desig as TEXT, and id is defined as number. also if i run the query on the table it self by contract_number , it works fine. only when am using the query in this code , its not working. Dunno wahts the mistake i did?? and have no clue ?? its just a simple line of code :~ Can any body guide ??
0 will always beats the 1.
You wrote: set classrecset1 = classdb1.OpenRecordset("select unit_price from contract_details where contract_number = ' " & a & " ' ") Nothing to say without seeing your table. Checkout "contract_number" is that string type or number. If Number type just remove the single quotes.