Your code makes no sense: You are assigning
a1
from
rs
, close the recordset, open it again with a new query, but never use the data from that query.
I would expect something like
rs.Open "Select * from Table1 where NameofTest='" + Label26.Caption + "'", con, adOpenDynamic, adLockPessimistic
If Not rs.EOF
a1 = rs.nameoftest
End If
rs.Close
If
NameofTest
is not unique, you have to use a loop instead:
While Not rs.EOF
a1 = rs.nameoftest
rs.MoveNext
End While
[EDIT]
Why do you hold the recordset opened?
Close it when not using it anymore. Because the code is called upon a user event (click) you can't use it in other functions where you don't know the state.
[EDIT]