Public Function GetValue(ID As Long, Num As Long)
Dim ReS
Dim Rs As DAO.Recordset
Set Rs = CurrentDb().OpenRecordset("select top 2 ..... where id=条件...")
If Rs.RecordCount = 0 Then
'数据源不存在
Exit Function
End If
If Num = 1 Then
ReS = Rs(目标字段)
Else
If Num = 2 Then
Rs.MoveNext
'在此加入代码,以保证在 RS 只有一条记录时不出错
ReS = Rs(目标字段)
End If
End If
GetValue = ReS
End Function