设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 4774|回复: 7
打印 上一主题 下一主题

How to Create your own custom Progress/Status Meter/Bar Chart

[复制链接]

点击这里给我发消息

跳转到指定楼层
1#
发表于 2005-8-16 21:00:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
标题:How to Create your own custom Progress/Status Meter/Bar Chart .

原作者:ATTAC Consulting Group

原文网址:http://ourworld.compuserve.com/homepages/attac-cg/AFormTip.htm#KEY

摘抄人:tmtony

翻译人:

You may find a need for creating a "rogress Meter" on your Form, separate from the status bar progress meter which is callable by using the sysCmd function in Access. A Progress meter can be created by using two label controls, directly on top of one another in the form. Here's how you do it:

1. Create a label control, with a sunken style, (we'll call this lblbase) and make it's back color transparent, and fore color to black.

2. Create a label control, of 0.00 width, identical in height to the lblbase (we'll call this lblmeter); align the lblmeter exactly with the left edge of the lblbase control, and send it to the back (i.e. behind the lblbase.) Make its edges transparent.

3. To update the progress meter place the following code in the form's module and send it the current and total amounts to measure progress as appropriate (you can use a timer event or place the calls in looping code etc.): Sub updatemtr (currentamt, totalamount)

'    This function changes the color based on progress.

'    You set the back color of lblmeter to be a single color if desired.



    Dim MtrPercent as Single

    MtrPercent = currentamt/totalamount

    Me!lblbase.Caption = Int(MtrPercent*100) & "%"

    Me!lblmeter.Width = CLng(Me!lblbase.Width * MtrPercent)

    Select Case MtrPercent

        Case Is < .33

            Me!lblmeter.BackColor = 255       'red

        Case Is < .66

            Me!lblmeter.BackColor = 65535   'yellow

        Case Else

            Me!lblmeter.BackColor = 65280   'green

    End Select

End Sub

4. Note this same tip can also be used to create a simple horizontal bar chart on a report, and is especially handy if you don't know what the total amount might be before you run the report. (The total amount would be required to be known a priori if you were to use MS Graph to create the chart, because you would have to set the scale when creating the chart; with this method, you don't have to know the total amount before the report is run.)
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2005-8-17 06:58:00 | 只看该作者
标题:How to Create your own custom Progress/Status Meter/Bar Chart .

如何制作你自定的進度/狀態條 與柱狀圖

原作者:ATTAC Consulting Group

原文网址:http://ourworld.compuserve.com/homepages/attac-cg/AFormTip.htm#KEY

摘抄人:tmtony

翻译人:chajiangliang

你可能發現有需要在你的窗體上要添加一個進度條﹐并且不是Access本身自帶的可通過syscmd函數使用的狀態條。 進度條可以使用兩個重疊的標簽控件來制作.以下是制作方法:1. 添加一個標簽控件﹐并設定其特別效果為陰影的﹐(我們給它命名為lblbase) 及背景色為透明的﹐前景色彩為黑色.2. 再添加一個寬度為0﹐高度與lblbase相同的標簽控件(我們給它命名為lblmeter); 將lblmeter與lblbase的左邊對齊﹐并將它送到最下層(在lblbase的下面)﹐設定框樣式為透明的。3. 要更新進度條﹐將以下代碼貼到窗體模組下面﹐再傳入適當的當前值與最大值(你可以使用timer事件或者將調用放在Loop循環中): Sub updatemtr (currentamt, totalamount)

   ' 此處的方法使進度條的顏色根據進度的變化而變化

   ' 如果你需要﹐也可以設定lblmeter的背景色為單一色。

    Dim MtrPercent as Single

    MtrPercent = currentamt/totalamount

    Me!lblbase.Caption = Int(MtrPercent*100) & "%"

    Me!lblmeter.Width = CLng(Me!lblbase.Width * MtrPercent)

    Select Case MtrPercent

        Case Is < .33

            Me!lblmeter.BackColor = 255       'red

        Case Is < .66

            Me!lblmeter.BackColor = 65535   'yellow

        Case Else

            Me!lblmeter.BackColor = 65280   'green

    End Select

End Sub4. 同樣此方法也適用與在報表上制作一個簡單的柱狀圖﹐尤其在你打開報表前不知道最大值是多少時非常方便.(如果你使用MS Graph去制作圖表﹐最大值作為前提是必需的﹐因為你制作圖表時必須繪制圖表的坐標;使用這種方法﹐你就可以不用在打開報表前知道最大值了.)
3#
发表于 2005-8-17 19:12:00 | 只看该作者
附例:[em01][em01][em01]



[此贴子已经被作者于2005-8-17 11:13:14编辑过]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2025-1-7 19:58 , Processed in 0.095407 second(s), 27 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表