我正在尝试检查表中字段的数据类型,如果它是 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/