access vba - Inconsistencies in looping through and creating reports -


i have database 5 tables, 3 queries, 3 reports (the queries recordsets) , 3 reports each showing several fields on recordsets. problem is, though have same code, 1 of sub routines has inconsistent results. cycling through each supervisor , creating report , doing again, it's caught in loop , can't see issue is. hoping can help.

private sub cmdfedinvest_click() dim x           string dim y           string dim strsql      string dim stwherestr  string 'where condition' dim stsection   string 'selection drop down list dim stfile      string dim stdocname   string dim stremail    string  strsql = "select distinctrow [qryactt8_sup].[sup], [qryactt8_sup].sup_email " & _ "from [qryactt8_sup];"     y = year(date)  dim db dao.database dim rst dao.recordset set db = currentdb dim qdtemp dao.querydef set qdtemp = db.createquerydef("", strsql) set rst = qdtemp.openrecordset()  if rst.eof , rst.bof     msgbox "no data available ledger process routine." else     debug.print rst.fields.count     rst.movefirst     while not rst.eof         x = rst![sup]         stremail = rst![sup_email]         stdocname = "fedinvest - issr - t8 recertification report"         stwherestr = "[qryactt8_sup].[sup]= '" & x & "'"         stfile = me.txtlocationsavefi & "\" & x & " - " & y & " fedinvest recertification.pdf"         docmd.openreport stdocname, acpreview, , stwherestr         'docmd.sendobject acsendreport, stdocname, acformatpdf, stremail, , , "2016 fedinvest recertification", ""         docmd.outputto acoutputreport, stdocname, acformatpdf, stfile         docmd.close acreport, stdocname         rst.movenext    loop end if rst.close set rst = nothing end sub 

you both open report preview , output pdf.

if pdf needed, skip preview.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo