線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1503
推到 Plurk!
推到 Facebook!

關於delphi列印Access報表的問題

答題得分者是:hagar
yang66530
一般會員


發表:2
回覆:2
積分:0
註冊:2009-08-31

發送簡訊給我
#1 引用回覆 回覆 發表時間:2009-08-31 15:36:59 IP:123.204.xxx.xxx 訂閱
請問各位大大:
要如何將舊有的Access資料庫內的報表,使用delphi程式叫出來列印,謝謝!
------
yang
hagar
版主


發表:143
回覆:4056
積分:4445
註冊:2002-04-14

發送簡訊給我
#2 引用回覆 回覆 發表時間:2009-08-31 16:56:57 IP:61.218.xxx.xxx 未訂閱
試試這個:

#83:How I can open a report (in Print Preview mode and also print direct) in an MS Access database?

http://www.scalabium.com/faq/dct0083.htm

var 
  Access: Variant; 
begin 
  {open the Access application}
  try 
    Access := GetActiveOleObject('Access.Application'); 
  except 
    Access := CreateOleObject('Access.Application'); 
  end; 
  Access.Visible := True;       { open the database 
   The second parameter specifies whether you want to open the 
   database in Exclusive mode}
  Access.OpenCurrentDatabase('C:\My Documents\Books.mdb', True);       { open the report 
   The value for the second parameter should be one of 
   acViewDesign, acViewNormal, or acViewPreview. acViewNormal, which is the
   default, prints the report immediately. If you are not using the type
   library, you can define these values like this:       const 
    acViewNormal = $00000000; 
    acViewDesign = $00000001; 
    acViewPreview = $00000002;       The third parameter is for the name of a query in the current 
  database. The fourth parameter is for a SQL WHERE clause - the string must
  be valid SQL, minus the WHERE.} 
  Access.DoCmd.OpenReport('Titles by Author', acViewPreview, EmptyParam, EmptyParam);     <...> 
  {close the database}
  Access.CloseCurrentDatabase;       {close the Access application}
  {const 
    acQuitPrompt = $00000000; 
    acQuitSaveAll = $00000001; 
    acQuitSaveNone = $00000002;} 
  Access.Quit(acQuitSaveAll); 
end;
yang66530
一般會員


發表:2
回覆:2
積分:0
註冊:2009-08-31

發送簡訊給我
#3 引用回覆 回覆 發表時間:2009-09-01 13:54:18 IP:123.204.xxx.xxx 訂閱
非常感謝板主很好用!

我不想顯示Access畫面,所以
Access.Visible := False; 設為不顯示
Access.DoCmd.OpenReport( ' TEST' ); 如此設定可以直接列印出來
------
yang
系統時間:2024-04-26 21:21:58
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!