database - Microsoft Access VBA - IF 语句总是计算 Else 表达式
问题描述
我想if
使用一些文本作为条件来构造一个语句。
在我的领域Status_anggota
中,有一个组合框,它的值是"Active"
或"Not active"
作为它的值。
我的问题是它不会得到的值,"Active"
所以它只显示错误的陈述:
Set db = CurrentDb()
Set rs = db.OpenRecordset("Select Status_anggota from Tbl_anggota Where Kode_anggota='" & Text2 & "'")
If rs.RecordCount = "Active" Then
MsgBox "Status is active", vbInformation
Else
MsgBox "Status is not active", vbInformation
End If
解决方案
尝试这个:
Set db = CurrentDb()
Set rs = db.OpenRecordset("Select Status_anggota from Tbl_anggota Where Kode_anggota='" & Text2 & "'")
If rs!Status_anggota.Value = "Active" Then
MsgBox "Status is active", vbInformation
Else
MsgBox "Status is not active", vbInformation
End If
推荐阅读
- python - Python中单元测试的装饰器问题
- c# - UWP:为多个播放器使用 1 个 MediaSource
- c - 编写一个程序,该程序将接受 5-95 范围内的整数值并作为 5 的倍数
- c++ - 如何在 debian 10 上运行 g++-6,需要编译旧的 buildroot 系统(交叉编译)
- wordpress - Wp查询日期之间的帖子,但任何年份
- android-studio - 安卓工作室:com.android。tools.build:gradle3.5.3 可用于离线模式
- grpc - 如何在不使用具体实例的情况下创建 dotnet gRPC 服务器
- mysql - 2个外键可以在一个表中引用另一个表中的同一列吗?
- opengl - 为什么 pyrr.Matrix44 转换似乎是列优先,而旋转行优先?
- if-statement - 如果 boolean true 或 false 在它的 else 中,重新检查外部