直接发代码,下面有错误。 TXT_BUMON = Rs2!BUMON 这句报错。值是null,怎么回事,求帮助
Private Sub Form_Open(Cancel As Integer)
Dim Ws1 As Workspace
Dim Db1 As Database
Dim Qd1 As QueryDef
Dim Rs1 As Recordset
Dim Rs2 As Recordset
' **<<初期設定>>**
Set Ws1 = DBEngine.Workspaces(0)
Set Db1 = Ws1.Databases(0)
' **<<抽出処理>>**
Set Rs1 = Db1.OpenRecordset("TZM001", DB_OPEN_SNAPSHOT)
Set Qd1 = Db1.CreateQueryDef("")
Qd1.Connect = MyODBC
Qd1.sql = "SELECT DISTINCT BUMON,BUMON_NM FROM MADB.dbo.TMA004(nolock)"
Qd1.sql = Qd1.sql & " WHERE KOUJO_CD = 7 AND BUMON >0 AND BUMON<4"
Set Rs2 = Qd1.OpenRecordset()
CID = Rs1!Tanmatu_ID '---<端末ID設定 >---
OID = Rs1!Tanto_ID '---<???????ID設定 >---
If IsNull(Rs1!TANTO_NM) Then
ONM = "" '---<???????ID設定 >---
Else
ONM = Rs1!TANTO_NM '---<???????ID設定 >---
End If
TXT_BUMON = Rs2!BUMON '---<部門CD設定 >---
BUMON_CD = Rs2!BUMON
BUMON_NM = Rs2!BUMON_NM '---<部門名設定 >---
------解决方案--------------------------------------------------------
调试下看Rs2的值是多少。