Access VBA Report Printing the Form Underneath -


i have bit of strange issue can't work out. have access database split front , end. 1 of forms has series of radio buttons , launch button, allowing user select report open. have attached photo of form below:

image1

when user loads selected report, opens in print preview mode, should.

image2

however, when user clicks print button in top left hand corner, 25% of time doesn't print report displayed, prints form underneath print preview. can't work 1 out. understand, print preview has focus because user clicking access print button screen.

as said, happens 25% of time, other 75% prints report normally. there nothing done different when prints incorrectly, , unable replciate issue, happens on own despite seemingly identical user inputs.

can point me in right direction?

edit following code run when display button clicked:

dim strlibrary string, strfromdate string, strtodate string, strcategory string dim strbooktype string, strbook string, strborrower string dim boobookseperatepages boolean, booborrowerseperatepages boolean, boogrouped boolean dim dtefromdate date, dtetodate date dim strpassedargument string, strwherestatement string, strand string  strfromdate = nz(cbofromdate, "") strtodate = nz(cbotodate, "")  if len(nz(cbofromdate, "")) = 0     dtefromdate = #1/1/1980# else     dtefromdate = cbofromdate end if  if len(nz(cbotodate, "")) = 0     dtetodate = date else     dtetodate = cbotodate end if  strcategory = nz(cbocategory, "") strbooktype = nz(cbotype, "") strbook = nz(cbobook, "") strborrower = nz(cboborrower, "") strlibrary = str(fralibrary) boobookseperatepages = chkbookseperatepages booborrowerseperatepages = chkborrowerseperatepages boogrouped = chkgroup  strwherestatement = "" strand = ""  strpassedargument = strlibrary & "|" & strfromdate & "|" & strtodate if cbofromdate.visible = true     if frareports = 20 or frareports = 21         strwherestatement = strwherestatement & strand & "[borrowdate] >= #" & dtefromdate & "# , [borrowdate] <= #" & dtetodate & "#"     else         strwherestatement = strwherestatement & strand & "[cataloguedate] >= #" & dtefromdate & "# , [cataloguedate] <= #" & dtetodate & "#"     end if     strand = " , " end if if cbocategory.visible = true     if len(cbocategory) > 0         strwherestatement = strwherestatement & strand & "[categoryid] = " & cbocategory         strand = " , "     end if end if if cbotype.visible = true     if len(nz(cbotype, "")) > 0         if nz(cbotype, 0) <> 0             strwherestatement = strwherestatement & strand & "[booktypeid] = " & cbotype             strand = " , "         end if     end if end if if fralibrary.visible = true     select case fralibrary         case 1             strwherestatement = strwherestatement & strand & "[booktypehasreader] = -1"             strand = " , "         case 2             strwherestatement = strwherestatement & strand & "[booktypehasreader] = 0"             strand = " , "     end select end if if cbobook.visible = true     if len(nz(cbobook, "")) > 0         strwherestatement = strwherestatement & strand & "[bookid] = " & cbobook             strand = " , "     end if end if if cboborrower.visible = true     if frareports = 13         if len(nz(cboborrower, "")) > 0             dim strsplitter() string             strsplitter = split(cboborrower, ", ")             strwherestatement = strwherestatement & strand & "[authorsurname] = '" & strsplitter(0) & "' , [authorfirstname] = '" & strsplitter(1) & "'"             strand = " , "         end if     else         if len(nz(cboborrower, "")) > 0 strwherestatement = strwherestatement & strand & "[borrowerid] = " & cboborrower         strand = " , "     end if end if  if frareports = 7     strwherestatement = strwherestatement & strand & "([digitised] = 'no' or [digitised] = 'n')"     strand = " , "     strwherestatement = strwherestatement & strand & "[booktypedesc] = 'tape'" end if  if frareports = 8     strwherestatement = strwherestatement & strand & "([remastered] = 'no' or [remastered] = 'n')"     strand = " , "     strwherestatement = strwherestatement & strand & "[booktypehasreader] = true" end if  select case frareports     case 0      'sorted title         if boogrouped = false             docmd.openreport "rptsortedbytitle", acviewpreview, , strwherestatement, acwindownormal, strpassedargument         else             docmd.openreport "rptsortbytitlegrouped", acviewpreview, , strwherestatement, acwindownormal, strpassedargument         end if     case 1      'sorted author         docmd.openreport "rptsortedbyauthor", acviewpreview, , strwherestatement, acwindownormal, strpassedargument     case 2      'grouped category         docmd.openreport "rptgroupedbycategory", acviewpreview, , strwherestatement, acwindownormal, strpassedargument     case 5      'grouped type         docmd.openreport "rptgroupedbytype", acviewpreview, , strwherestatement, acwindownormal, strpassedargument     case 3      'duplicate books         msgbox "opening duplicate books form...."     case 4         docmd.openreport "rptrecentadditions", acviewpreview, , strwherestatement, acwindownormal, strpassedargument     case 7      'books not yet digitised         docmd.openreport "rptnotdigitised", acviewpreview, , strwherestatement, acwindownormal, strpassedargument     case 8      'books not yet remastered         docmd.openreport "rptnotremastered", acviewpreview, , strwherestatement, acwindownormal, strpassedargument     case 10     'borrower's history         if chkborrowerseperatepages = true             docmd.openreport "rptborrowershistoryseperate", acviewpreview, , strwherestatement, acwindownormal, strpassedargument         else             docmd.openreport "rptborrowershistory", acviewpreview, , strwherestatement, acwindownormal, strpassedargument         end if     case 11     'book history         if chkbookseperatepages = true             docmd.openreport "rptbookhistoryseperate", acviewpreview, , strwherestatement, acwindownormal, strpassedargument         else             docmd.openreport "rptbookhistory", acviewpreview, , strwherestatement, acwindownormal, strpassedargument         end if     case 12        'book lending count         docmd.openreport "rptbooklendingcount", acviewpreview, , strwherestatement, acwindownormal, strpassedargument     case 13        'book lending count author         docmd.openreport "rptbooklendingcountauthor", acviewpreview, , strwherestatement, acwindownormal, strpassedargument     case 14        'books borrowed count         if strtodate <> "" , strfromdate <> ""             strpassedargument = "histborrowdate >=#" & strfromdate & "# , histborrowdate <=#" & strtodate & "#|" & strlibrary & "|from " & strfromdate & " " & strtodate         elseif strtodate <> "" , strfromdate = ""             strpassedargument = "histborrowdate <=#" & strtodate & "#|" & strlibrary & "|before " & strtodate         elseif strtodate = "" , strfromdate <> ""             strpassedargument = "histborrowdate >=#" & strfromdate & "#|" & strlibrary & "|after " & strfromdate         else             strpassedargument = "|" & strlibrary & "|"         end if         docmd.openform "frmbooksborrowedcount", acnormal, , , , acdialog, strpassedargument     case 20        'books on loan sorted title         docmd.openreport "rptbooksonloantitle", , , strwherestatement, acwindownormal, strpassedargument     case 21        'books on loan sorted borrower         if chkborrowerseperatepages = true             docmd.openreport "rptbooksonloanborrowersep", acviewpreview, , strwherestatement, acwindownormal, strpassedargument         else             docmd.openreport "rptbooksonloanborrower", acviewpreview, , strwherestatement, acwindownormal, strpassedargument         end if     case 22        'lost/damaged books         strwherestatement = strwherestatement & strand & "[bookstatusid] = 3 or [bookstatusid] = 4 or [bookstatusid] = 7"         docmd.openreport "rptlostdamagedbooks", acviewpreview, , strwherestatement, acwindownormal, strpassedargument     case 23        'statistics         docmd.openform "frmstatistics", acnormal, , , , acdialog     case 24        'books reserved         docmd.openreport "rptbooksreserved", acviewpreview, , strwherestatement, acwindownormal, strpassedargument     case 25        'list borrowers         docmd.openreport "rptlistallborrowers", acviewpreview, , strwherestatement, acwindownormal, strpassedargument end select 


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -