Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADODC - testing if recordset is Open

Status
Not open for further replies.

demoman

Programmer
Oct 24, 2001
242
US
I sometimes use the ADODC control for binding data to AX controls. I am trying to make things more efficient, and only open the adodc recordset as needed. I want to first make sure what the .state property is at before I open/close it because someone thought that should be an error, instead of just ignoring it if it was already open/close. Trouble is you cannot write:

if ado.recordset.state = 1 then

if it is closed, since the recordset object does not exist. Any ideas on this?

Thanks
 
What if you first try:

If IsObject(ado.recordset) Then
...

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Maybe this is what your looking for.

If Not rs Is Nothing Then
If rs.State <> adStateClosed Then
rs.Close
End If
Set rs = Nothing
End If
 
This works well too.

With MyRS
If MyRs.state=1 then MyRS.close
.active connection=....
.cursortype=....
.cursorlocation=...
.source="whatever"
.open
End with


Dan
 
Thanks to everyone for their input - much appreciated. Turns out (through process of elimination), if the .visible property is True AND the control references a TABLE, then you cannot read the .State property. Evidently, this once made sense to someone, or it makes sense to everyone but me.

Thanks and Peace
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top