Link to home
Start Free TrialLog in
Avatar of Tom Crowfoot
Tom CrowfootFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Iff Statement based on record count

Dear Experts

I am building a news letter database which will send out various stories which have been categorized.  In the body of the email I have a series of RST recordsets to insert the story headlines by category.

Each category is defined by its own query & the RST loops get compiled at the end of the code. This all works fine, but what I would like to do is this ...

If a category contains no story then I want that part of the string to be null.  So in the example below I have inserted where I would like the if statement to run


' .....................................................................................................

' RST Insurance
Dim rstInsurance As Recordset
    
    Set rstInsurance = CurrentDb.OpenRecordset("Newsletter FS Sub Insurance")
    Do While Not rstInsurance.EOF
   


EmailBodyHeadlinesInsurance = EmailBodyHeadlinesInsurance & "<li>" & rstInsurance!title & "</li>"
 rstInsurance.MoveNext
    Loop
    rstInsurance.Close


' ... insert here something that states if record set is empty then EmailBodyHeadlinesInsurance = "" else EmailBodyHeadlinesInsurance  = "INSURANCE <br>" &  EmailBodyHeadlinesInsurance  

Open in new window


Can anybody help?
ASKER CERTIFIED SOLUTION
Avatar of Barry Cunney
Barry Cunney
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tom Crowfoot

ASKER

Perfect - works a treat thank you very much