Access讲座
网站公告
·Access快速平台QQ群号:156702533    ·Access快速开发平台下载地址及教程    ·欢迎添加微信交流账号:AccessoftChu    ·如何快速搜索本站文章|示例|资料    
您的位置: 首页 > 技术文章 > Access数据库-模块/函数/VBA

dFirst()函数

时 间:2020-03-21 07:49:54
作 者:souelove   ID:7327  城市:郑州
摘 要:dFirst()
正 文:

' ***************************
    ' Typical Use
    ' Numerical values. Replace "number" with the number to use.
    variable = DFirst("[FieldName]", "TableName", "[Criteria] = number")

    ' Strings.
    ' Numerical values. Replace "string" with the string to use.
    variable = DFirst("[FieldName]", "TableName", "[Criteria]= 'string'")

    ' Dates. Replace "date" with the string to use.
    variable = DFirst("[FieldName]", "TableName", "[Criteria]= #date#")
    ' ***************************

    ' ***************************
    ' Referring to a control on a form
    ' Numerical values
    variable = DFirst("[FieldName]", "TableName", "[Criteria] = " & Forms!FormName!ControlName)

    ' Strings
    variable = DFirst("[FieldName]", "TableName", "[Criteria] = '" & Forms!FormName!ControlName & "'")

    ' Dates
    variable = DFirst("[FieldName]", "TableName", "[Criteria] = #" & Forms!FormName!ControlName & "#")
    ' ***************************

    ' ***************************
    ' Combinations
    ' Multiple types of criteria
    variable = DFirst("[FieldName]", "TableName", "[Criteria1] = " & Forms![FormName]![Control1] _
             & " AND [Criteria2] = '" & Forms![FormName]![Control2] & "'" _
            & " AND [Criteria3] =#" & Forms![FormName]![Control3] & "#")
    
    ' Use two fields from a single record.
    variable = DFirst("[LastName] & ', ' & [FirstName]", "tblPeople", "[PrimaryKey] = 7")
            
    ' Expressions
    variable = DFirst("[Field1] + [Field2]", "tableName", "[PrimaryKey] = 7")
    
    ' Control Structures
    variable = DFirst("IIf([LastName] Like 'Smith', 'True', 'False')", "tableName", "[PrimaryKey] = 7")
    ' ***************************


Access软件网QQ交流群 (群号:143677707)       access源码网店

最新评论 查看更多评论(1)

2020/3/22 0:05:18大音稀声
谢谢分享!旧知识有新收获!

发表评论您的评论将提升作者分享的动力!快来评论一下吧!

用户名:
密 码:
内 容:
 

常见问答

技术分类

相关资源

关于我们 | 服务条款 | 在线投稿 | 友情链接 | 网站统计 | 网站帮助