Set rs = cn.Execute("SELECT AAA FROM TB ORDER BY AAA")
i = 1
Do Until rs.EOF
Do While Val(rs!AAA) > i
Text1 = Text1 & Right("00" & CStr(i), 3) & " "
i = i + 1
Loop
i = i + 1
rs.MoveNext
Loop
少了个end if
sub cmdTest_click
dim rs as adodb.recordset
Set rs = cn.Execute("SELECT AAA,值字段 FROM TB"))
with rs
if .recordcount>0 then
.movefirst
while not .eof
Text1 = Text1 & (rs(值字段) & "")
.movenext
wend
end if
end with
end sub
sub cmdTest_click
dim rs as adodb.recordset
Set rs = cn.Execute("SELECT AAA,值字段 FROM TB"))
with rs
if .recordcount>0 then
.movefirst
while not .eof
Text1 = Text1 & (rs(值字段) & "")
.movenext
wend
end with
end sub
在库中建立一个与 TB 结构相同的临时表,如 temp。将 temp 先填充完整的数据(例如 '001' 至 '999'):
Set rs = cn.Execute("SELECT AAA FROM temp WHERE AAA Not In (SELECT AAA FROM TB) AND AAA < (SELECT Max(AAA) FROM TB))
Text1 = ""
Do Until rs.EOF
Text1 = Text1 & rs!AAA & " "
Loop