设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

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

[与其它组件] 看见切换面板的源代码,请高手指导

[复制链接]
跳转到指定楼层
1#
发表于 2005-8-17 16:34:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
无意中打开了切换面板的源代码,但许多看不懂,看懂了的就加了注释,哪位高手能补一补全啊

Option Compare Database

Private Sub Form_Open(Cancel As Integer)切换面板打开时的代码

' Minimize the database window and initialize the form.最小化数据库窗口和切换面板的初始化

    ' Move to the switchboard page that is marked as the default.切换面板移动到默认位置

    Me.Filter = "[ItemNumber] = 0 AND [Argument] = 'Default' "窗体的筛选属性初始值:项目数为0,对正为默认值

    Me.FilterOn = True筛选属性有效

   

End Sub

Private Sub Form_Current()窗体刷新时发生的程序代码

' Update the caption and fill in the list of options.更新名称和掩码

    Me.Caption = Nz(Me![ItemText], "")窗体的名称为项目的名称,如果没有项目,通过NZ函数也不会出错

    FillOptions调用掩码选项的函数

   

End Sub

Private Sub FillOptions()掩码选项的函数

' Fill in the options for this switchboard page.给切换面板设置掩码

    ' The number of buttons on the form.按钮的数目

    Const conNumButtons = 8最大按钮数目为8

   

    Dim con As Object

    Dim rs As Object

    Dim stSql As String

    Dim intOption As Integer

   

    ' Set the focus to the first button on the form,将焦点移动到第一个按钮上

    ' and then hide all of the buttons on the form将全部按钮隐藏

    ' but the first.  You can't hide the field with the focus.但第一个按钮除外,你不可能隐藏焦点控件

    Me![Option1].SetFocus将焦点移动到第一个按钮上

    For intOption = 2 To conNumButtons从第二个按钮开始到全部按钮

        Me("Option" & intOption).Visible = False按钮不可见

        Me("OptionLabel" & intOption).Visible = False按钮的说明文字也不可见

    Next intOption

   

    ' Open the table of Switchboard Items, and find在切换面板上展开各个项目

    ' the first item for this Switchboard Page.

    Set con = Application.CurrentProject.Connection给当前的联接对象命名,以便引用它

    stSql = "SELECT * FROM [Switchboard Items]"设定SQL语句,一句写太长不好看,它分成三句写

    stSql = stSql & " WHERE [ItemNumber] > 0 AND [SwitchboardID]=" & Me![SwitchboardID]

    stSql = stSql & " ORDER BY [ItemNumber];"

    Set rs = CreateObject("ADODB.Recordset")这个不知道是什么对象

    rs.Open stSql, con, 1   ' 1 = adOpenKeyset这OPEN函数有三参数,什么意思懒得去看

   

    ' If there are no options for this Switchboard Page,如果切换面板上没有项目(按钮)

    ' display a message.  Otherwise, fill the page with the items.显示项目并查找面板

    If (rs.EOF) Then转换数据库代码

        Me![OptionLabel1].Caption = "There are no items for this switchboard page"

    Else

        While (Not (rs.EOF))

            Me("Option" & rs![ItemNumber]).Visible = True按钮可见

            Me("OptionLabel" & rs![ItemNumber]).Visible = True标签文字可见

            Me("OptionLabel" & rs![ItemNumber]).Caption = rs![ItemText]标签文字为项目的标题

            rs.MoveNext

        Wend

    End If

    ' Close the recordset and the database.将这两个数据对象关闭

    rs.Close

    Set rs = Nothing

    Set con = Nothing

End Sub

Private Function HandleButtonClick(intBtn As Integer)

' This function is called when a button is clicked.

' intBtn indicates which button was clicked.

    ' Constants for the commands that can be executed.

    Const conCmdGotoSwitchboard = 1

    Const conCmdOpenFormAdd = 2

    Const conCmdOpenFormBrowse = 3

    Const conCmdOpenReport = 4

    Const conCmdCustomizeSwitchboard = 5

    Const conCmdExitApplication = 6

    Const conCmdRunMacro = 7

    Const conCmdRunCode = 8

    Const conCmdOpenPage = 9

    ' An error that is special cased.

    Const conErrDoCmdCancelled = 2501

   

    Dim con As Object

    Dim rs As Object

    Dim stSql As String

On Error GoTo HandleButtonClick_Err

    ' Find the item in the Switchboard Items table

    ' that corresponds to the button that was clicked.

    Set con = Application.CurrentProject.Connection

    Set rs = CreateObject("ADODB.Recordset")

    stSql = "SELECT * FROM [Switchboard Items] "

    stSql = stSql &amp
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-3 03:43 , Processed in 0.100210 second(s), 24 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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