using VBA to determine report field content

M

Mark J Kubicki

I have a report where several of the fields content is best(?) determined by
putting them into code (I had tried SQL, but that was beyond cumbersome)
the content would be based on the value of other fields in the same or other
tables

the code I have entered for the report field txtDescription might be
something like this
what it results in is the information for record 1, not being shown at all
in record 1 of the report, but showing in record 2, and every subsequent
record in the report

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Dim dbs As Database
Dim rst As DAO.Recordset
Dim rst1 As DAO.Recordset
Dim rst2 As DAO.Recordset
Dim strDescription As String

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("FixtureTypesNoProject", dbOpenSnapshot)
Set rst1 = dbs.OpenRecordset("projectninfo", dbOpenSnapshot)
Set rst2 = dbs.OpenRecordset("tblFixtureSchedulePrintoptions",
dbOpenSnapshot)

strDescription = ""
strDescription = strDescription & (rst!basedescription + " ")
If rst2!ShortDescription <> "false" Then
If rst!PrintAddDescription Then
strDescription = strDescription & (rst!AdditionalDes + " ")
End If
End If
....
Me.txtDescription = strDescription


thanks in advance,
mark
 
Top