連續(xù)或者單個(gè)窗體,如何打印當(dāng)前顯示的記錄?當(dāng)前窗體還有對(duì)應(yīng)的子窗體,也要一起打印出來
我在一個(gè)窗體里有一個(gè)單號(hào),大子窗體里有幾組數(shù)據(jù),我的報(bào)表是一組數(shù)據(jù)一頁,請(qǐng)問如何實(shí)現(xiàn)按一下打印,能夠只打印當(dāng)前單號(hào)的數(shù)據(jù)報(bào)表?
回答:
這個(gè)問題太簡單,我就不另外做說明了,請(qǐng)去看羅斯文示例數(shù)據(jù)庫的“訂單”窗體上“打印發(fā)貨單”按鈕的單擊事件的代碼
http://access911.net/down/eg/northwind2003.rar
http://access911.net/down/eg/northwind97.rar
sub 打印發(fā)貨單_click()
' 這段代碼由“命令按鈕向?qū)А眲?chuàng)建。
on error goto err_printinvoice_click
dim strdocname as string
strdocname = "發(fā)貨單"
' 打印“發(fā)貨單”報(bào)表,使用“發(fā)貨單篩選”查詢打印當(dāng)前訂單的發(fā)貨單。
docmd.openreport strdocname, acviewnormal, "發(fā)貨單篩選"
exit_printinvoice_click:
exit sub
err_printinvoice_click:
' 如果用戶取消操作,不顯示錯(cuò)誤消息。
const conerrdocmdcancelled = 2501
if (err = conerrdocmdcancelled) then
resume exit_printinvoice_click
else
msgbox err.description
resume exit_printinvoice_click
end if
end sub
這里的docmd.openreport strdocname, acviewnormal, "發(fā)貨單篩選" 的"發(fā)貨單篩選"參數(shù)是一個(gè)查詢的名稱,該查詢代碼如下:
select 發(fā)貨單.*
from 發(fā)貨單
where (((發(fā)貨單.訂單id)=forms!訂單!訂單id));
請(qǐng)去參考一下 openreport 的語法,在 access 幫助里面有。
新聞熱點(diǎn)
疑難解答
圖片精選