Report Conditional Statement

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

A letter is created using the Report Generator. The report references two
appointment dates.

"ie. your client is scheduled for 5/5/05 and 5/9/05"

Currently the database has only one date field assigned. In the Registration
table, is a list of appointments that contains a unique registrationID and
AttendeeID.

I'm looking for how to get started and where to place the statement. I'm
anticipating an If statement but really need some guidance. Any reference
material to study is appreciated also.
 
I'm looking for how to get started and where to place the statement.
I'm anticipating an If statement but really need some guidance. Any
reference material to study is appreciated also.

outputText = ""

jetSql = "SELECT ApptDate FROM Registrations " & _
"WHERE AttendeeID = 10992 " & _
"ORDER BY ApptDate ASC;"

set rs = db.OpenRecordset(jetSql, dbOpenSnapshot, dbForwardOnly)

Do While Not rs.EOF
if len(outputText)=0 then
outputText = "ie. your client is scheduled for "
else
outputText = outputText & " and for "
end if
outputText = outputText & format(rs!ApptDate,"dd/nn/yyyy")

rs.MoveNext
Loop

If len(outputText)=0 Then
outputText = "Your client has no appointments due."

End if

You can place this in a suitable event in the report; for example the
Section_Format event; and finish it off with something like

txtAppointmentsParagraph.Value = outputText

in order to place the stuff on the report itself. It's hard to be any
more explicit without knowing more about your situation. If you need to
know more, I would guess a good starting place would be the Help files on
'Order of Events on Reports'.

Hope that helps


Tim F
 
Thanks Tim,

Yes, this is a big help.

Tim Ferguson said:
outputText = ""

jetSql = "SELECT ApptDate FROM Registrations " & _
"WHERE AttendeeID = 10992 " & _
"ORDER BY ApptDate ASC;"

set rs = db.OpenRecordset(jetSql, dbOpenSnapshot, dbForwardOnly)

Do While Not rs.EOF
if len(outputText)=0 then
outputText = "ie. your client is scheduled for "
else
outputText = outputText & " and for "
end if
outputText = outputText & format(rs!ApptDate,"dd/nn/yyyy")

rs.MoveNext
Loop

If len(outputText)=0 Then
outputText = "Your client has no appointments due."

End if

You can place this in a suitable event in the report; for example the
Section_Format event; and finish it off with something like

txtAppointmentsParagraph.Value = outputText

in order to place the stuff on the report itself. It's hard to be any
more explicit without knowing more about your situation. If you need to
know more, I would guess a good starting place would be the Help files on
'Order of Events on Reports'.

Hope that helps


Tim F
 
Back
Top