jwcolby
jwcolby at colbyconsulting.com
Wed Sep 30 06:57:18 CDT 2009
There are several variations. MyVar = rst("FldName").value MyVar = rst!FldName.Value MyVar - rst(MyIndex).Value The first is used if you have the NAME of the field in a string variable. The second is when you know the field name but do not have it stored in a string variable. The third is when you are working through the fields using a numeric integer as a field collection index. John W. Colby www.ColbyConsulting.com John Bartow wrote: > What is the syntax to set a variable to a field's value in the current row > of a recordset? > > ---------------------------------------------------------------------------- > -- > Private Sub PrintAllReports() > 'Loops through AddressData table and prints all customer reports > > Dim db As Database > Dim rs As Recordset > Set db = CurrentDb > Dim lngAcctNum As Long > > lngSum = 0 > > Set rs = db.OpenRecordset("SELECT * FROM AddressData ORDER BY > TrayNumber") > Do While Not rs.EOF > 'set variable to lngAcctNum current AccountNumber field to use as > filter in each report > lngAcctNum = > 'Print Report 1 using: AccountNumber = lngAcctNum as report filter > 'Print Report 2 using: AccountNumber = lngAcctNum as report filter > 'Print Report 3 using: AccountNumber = lngAcctNum as report filter > rs.MoveNext > Loop > rs.Close > > End Sub > ---------------------------------------------------------------------------- > -- > >