日記帳
本ページはプロモーションが含まれています
カテゴリー
Links
blog(ブログ)マスター
アンドロイドの巣
ゼロから始めるベランダ菜園
タイトル
ラジコン
2024年4月
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30

Office操作アクセス編01:Access.Application

カテゴリー: Office
2005-01-30 09:34
さぁ アクセスをしもべにしよう 編{/hakushu/}

procedure TForm1.Button1Click(Sender: TObject);
var s: Variant;
accFormCount,accControlCount, i : integer;
// AccessTextBox : TAccessTextBox;
begin
AccessApplication1.Connect;
AccessApplication1.Visible := True;
AccessApplication1.OpenCurrentDatabase(
ExtractFilePath(ParamStr(0) )+ 'db1.mdb',false);
AccessApplication1.DoCmd.OpenForm('フォーム1'
,acNormal{0} ,'OutputAllFields','',acFormEdit{1},
acWindowNormal{0},'');
ListBox1.Clear; // フォームのリスト
ListBox2.Clear; // フォームに配置されたコントロール
s := false;
// 開いてからでないと取得できない。
for accFormCount := 0 to AccessApplication1.Forms.Count-1 do
begin
ListBox1.Items.Add(AccessApplication1.Forms.Item[accFormCount].Name);
if (AccessApplication1.Forms.Item[accFormCount].Name ='フォーム1') then
begin i := accFormCount; s := True; { break;} end;
end;
if s then
begin
s := AccessApplication1.Forms.Item[i].accFocus;
if (s.name='テキスト0') then s.text := 'わーい♪';
s := true;
end;
if s then
for accControlCount := 0 to AccessApplication1.Forms.Item[i].Controls.Count -1 do
begin
s := AccessApplication1.Forms.Item[i].Controls.Item[accControlCount];
ListBox2.Items.Add(s.name);
if s.name='ラベル1' then
s.Caption := '発見';// Form:フォーム1.テキスト0.Text
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
AccessApplication1.CloseCurrentDatabase;
AccessApplication1.Disconnect;
end;

OLEから操作の説明リンク
http://www.dsdt.info/tipps/?id=607


ブログ内 関連記事: Office操作アクセス編01 Access.Application

 関連記事はありません。

ブログ内 関連記事: Office操作アクセス編01 Access.Application

 関連記事はありません。
トラックバック
トラックバックはありません。
PR

[PR]