我对编程非常陌生(我不是程序员),并且对发生的问题深有了解。
我有一个包含81个字段的表(TEmp02
),但是我试图仅遍历78个字段以获取值并将其分配给声明的公共数组(作为变量empArray.emptblarr
)在一个模块中。
尽管填充了表字段,但某些值返回为Null
' to populate the form controls if already the entered empid exists
Dim adocmd As New ADODB.Command
Dim adors As New ADODB.Recordset
'open recordset
adocmd.ActiveConnection = adoconn
adocmd.CommandText = "SELECT TEmp02.* FROM TEmp02"
adors.Open adocmd, , adOpenForwardOnly
Dim j As Integer
j = adors.Fields.Count - 3 'don't require 3 fields out of 81
ReDim empArray.emptblarr(j)
adors.Filter = "empID = " & Me.cbo_emid
If adors.RecordCount = 0 Then
MsgBox "Making a new Employee Entry", vbOKOnly, "Employee ID"
Exit Sub
Else
' populate the form controls with the existing latest field data
adors.MoveLast
Dim i As Integer
j = 0
For i = 2 To adors.Fields.Count - 1 Step 1
empArray.emptblarr(j) = adors.Fields(i)
j = j + 1
Debug.Print adors.Fields(i)
Next i
adors.Close
Set adors = Nothing
Set adocmd = Nothing
End If
这是主要形式,当我在循环中执行debug.print adors.fields(i)时,得到的结果为null。结果是:
2222
tshering
Null
dorji
tsd
td@gmail.com
12457845
21
PIC222206282018.jpg
55
LIC06282018.pdf
6/8/2018
6/15/2018
Null 'This should not have been null
6/16/2018
2
Null ' This should not have been null
6/16/2018
2
6/16/2018
2
6/16/2018
2
6/16/2018
2
6/16/2018
2
6/16/2018
2
6/16/2018
2
6/16/2018
2
6/16/2018
2
6/16/2018
2
6/16/2018
2
6/16/2018
2
6/16/2018
2
6/16/2018
2
6/16/2018
2
6/16/2018
2
6/16/2018
2
6/16/2018
2
6/16/2018
2
6/16/2018
2
6/16/2018
2