vba - Visual Basic - 检查 If 语句中的记录集字段类型

标签 vba ms-access types

我正在尝试检查表中字段的数据类型,如果它是 Text 类型,则让代码做一件事,如果它是任何其他类型,则让代码做另一件事。下面是我拥有的代码,但我认为我根本没有正确的第三行。任何帮助将不胜感激!

Set dbExample = CurrentDb
Set rsTester = dbExample.OpenRecordset("tester", dbOpenDynaset)
If TypeOf rsTester!exampleField Is Text Then
    'Does what the code needs to do
Else
    'Does what the code needs to do
End If
rsTester.Close

最佳答案

TypeOf未与 DAO 一起使用 Field对象。你想做的是更像

If rsTester("exampleField").Type = dbText Then
    ' do the thing
Else
    ' do the other thing
End Select

关于vba - Visual Basic - 检查 If 语句中的记录集字段类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13615144/

相关文章:

arrays - 在 Excel 中检索模式数组的值

vba - 删除 Material list 中的行

database - 将两个 Microsoft Access 数据库合并为一个,并在它们之间进行选择

sql - 当记录数达到一定值时,备注字段显示汉字或符号而不是实际值

Android API 与 renderscript.type 类不一致

reactjs - npm 更新后 React 无状态组件损坏

excel - BizTalk BAM Excel "Unable to get resource string"

excel - 如何修复第二个errHandler

c# - 处理查询中不需要的 MS Access 文本字段的最安全实用方法是什么?

c# - 如何覆盖 TryParse?