vba - Print Dialog in MS-Access -


i want open print dialog box. haven't programmed in vb decade , more little rusty.

i got copy of ms access vb script selects mdb file , prints 1 copy. thought process was:

  1. open dialog box;
  2. select printer;
  3. type in number of copies;
  4. print.

currently, portion of original script want modify is:

[sql query above this] ....  ' open form dim rs dao.recordset set rs = db.openrecordset("select@@identity") debug.print rs(0)  dim q string q = "transfer_id=" & rs(0) docmd.openform "transfer report", acnormal, , q, ,acdialog docmd.printout  ... [end if, end sub, etc.] 

this prints out 1 instance of report , company not have ability print out other copies @ same time. since in field, don't have access copier still need multiple copies.

one answer found, david-w-fenton (thank you!), shows how create dialog box; following script accomplish want do? and, how add portion dialog box specify how many copies print?

...   dim varprinter printer dim strrowsource string dim q string dim rs dao.recordset  set rs = db.openrecordset("select @@identity") debug.print rs(0)  if len(me.openargs) > 0   q = me.openargs   me.tag = q   each varprinter in application.printers    strrowsource = strrowsource & "; " & varprinter.devicename   next varprinter   me!cmbprinter.rowsource = mid(strrowsource, 3)   ' first check see report still open if (1 = syscmd(acsyscmdgetobjectstate, acreport, q))    reports(q).printer      me!cmbprinter = .devicename      me!optlayout = .orientation      end     me!txtpageto = reports(q).pages   end if end if  public function printreport(q string) boolean   q = "transfer_id=" & rs(0)  ' open report in preview mode hidden  docmd.openreport q, acviewpreview, , , achidden  ' open dialog form let user choose printing options  docmd.openform "dlgprinter", , , , , acdialog, q  forms!dlgprinter    if .tag <> "cancel"     set reports(q).printer = application.printers((!cmbprinter))     reports(q).printer.orientation = !optlayout     application.echo false     docmd.selectobject acreport, q     docmd.printout acpages, !txtpagefrom, !txtpageto     printreport = true    end if  end  docmd.close acform, "dlgprinter"  docmd.close acreport, q  application.echo true end function 

here late reply, times may others.

in order open print dialogue:

place command button print on report, , write code below.

private sub cmdbtnprint_click() docmd.runcommand accmdprint end sub 

change 'display when' property of button 'screen only'.

open report in 'acviewreport' view mode.

click print command button, , systems print dialogue box open. set parameters , print report.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -