With rs
.CursorType = adOpenStatic 'I tried all types
.LockType = adLockOptimistic 'I tried all types
.CursorLocation = adUseClient
.Open com
End With
while rs.EOF = False
if val(t1.text) = rs.fields(1) then
msgbox "Reg.no. " & rs.fields(1) & " is Already in database"
'Our Searching work in db is done here, we want to close this while loop by code, so i used below
rs.EOF = True 'here compiler error gives "can't assign to read-only property"
else
rs.movenext
end if
wend
'here want to do " if not val(t1.text) = rs.fields(1) " operation
请帮助分配读/写属性,如果它不能告诉我另一个解决方案来关闭这个条件/ while循环......
答案 0 :(得分:3)
不,你不能设置rs.EOF = True,因为它是一个只读属性,但是你可以从循环中逃脱。 尝试类似的东西:
Do while Not rs.EOF
if val(t1.text) = rs.fields(1) then
msgbox "Reg.no. " & rs.fields(1) & " is Already in database"
Exit Do
end if
rs.movenext
Loop
rs.close