So I am writing a string in VBA. It needs to use 2 different numeric variables from a form that the user clicked on. My code works great if I only use 1 variable, but I can't get the syntax correct for 2 variables. Here is what I originally wrote that works fine.
stringSQL = "select table1.field1, table2.field2 from table1 where table1.flag='flag' and
table1.weight = " & [Forms]![myform]![weight]
When I try to add age to the string (I want to use age and weight from myform) I write this which does not work -
stringSQL = "select table1.field1, table2.field2 from table1 where table1.flag='flag' and
table1.age= " & [Forms]![myform]![age] & " and " & table1.weight= " &
[Forms]![myform]![weight]