|
高手们,请教啦!
Dim myop As String
Dim mycount As Integer
Dim mydb As Database
Dim myrst As Recordset
Set mydb = CurrentDb()
myop = DLookup("op_no", "dbo_work_op_card", "card_no='" & card_no & "'")
Set myrst = mydb.OpenRecordset("select distinct item_length from dbo_work_op_prod where op_no='" & myop & "'")
mycount = myrst.RecordCount
'mycount 结果为1,正确的应为3
Set myrst = mydb.OpenRecordset("select distinct item_length from work_op_prod where op_no='" & myop & "'")
mycount = myrst.RecordCount
'mycount 结果为3
不知何故用链接表的mycount 结果为1,正确的应为3。链接表上符合条件的item_length查过确为3条记录。
注:work_op_prod为dbo_work_op_prod用生成表查询而得的本地表,两表记录应是完全一致的。
我还试过Set myrst = mydb.OpenRecordset("select distinct item_length from work_op_prod where op_no='" & myop & "'")mycount = myrst.RecordCount'mycount 结果为3 但Set myrst = mydb.OpenRecordset("select * from work_op_prod where op_no='" & myop & "'")mycount = myrst.RecordCount却返回1
我也试过用调试跟踪,再将跟踪结果copy到新建的一个查询中,运行后也得到三条记录,但RecordCount却返回1,为什么呢? |
|