Been working on some programming exercises in my spare time and don't fully understand this one related to ADO....Appreciate any help on this.
The name of the ADO data control is adoNum-----Was trying to figure which one of these statements would multiply the contents of the fldNum1 field by 3 and then store the result in the fldTot field?
adoNum.Fields(fldTot) = adoNum.Fields(fldNum1) * 3
adoNum.Fields("fldTot") = adoNum.Fields("fldNum1") * 3
adoNum.Recordset.Fields(fldTot) = adoNum.Recordset.Fields(fldNum1) * 3
adoNum.Recordset.Fields("fldTot") = adoNum.Recordset.Fields("fldNum1") * 3
OK, Im not quite sure what your adoNum is defined as. I assume it is a recordset though the way you have it displayed here.
That being the case this line would be your best bet I suppose
adoNum.Fields("fldTot") = adoNum.Fields("fldNum1") * 3
Though I would recommend setting your entire recordset into variables before manipulating, especially if the data types are not set in the tables to integers
-
dim TotalNum as Integer
-
dim FieldNum as Integer
-
FieldNum = adoNum.Fields("fldNum1")
-
TotalNum = FieldNum * 3
-
adoNum.Fields("fldTot") = TotalNum
-
adoNum.Update
-
However, you have to still perform an update on your recordset once your field values are set, assuming you are "on" the right record in your code.