Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Problem with ADO Connection

darthmoobeydarthmoobey Member Posts: 140

I have created a payroll program using visual basic 6.0, and appear to be having a problem with one of my ADO commands.

The program takes information from Employee hours and compares it to approved client hours. To do this I must query and compare information from two databases, billing and payroll DBs. Things are working ok, but I am getting a strange error code

run-time error 3219
Operation is not allowed in this context.

If Val(DateDay) <= 531 And Val(DateDay) >= 516 Then
BM2000MAY2.Find "ClientNumber =" & clinum
If BM2000MAY2.EOF = False Then
ResetClientHours = BM2000MAY2.Fields("WrkHours").Value
BM2000MAY2.Fields("WrkHours").Value = ResetClientHours - ResetProvHours
If BM2000MAY2.Fields("WrkHours").Value < 0 Then
BM2000MAY2.Fields("WrkHours").Value = 0
End If
End If
BM2000MAY2.Close '<--- this is where the error points to
End If

The program will not allow me to close the recordset after the search.
If I remove it, I get the error message here.

Function Open_2000MAY2()
'checking for instance of open recordset, if open it will close it
If BM2000MAY2.State = adStateOpen Then
BM2000MAY2.Close '<--- this is where I get the message now
End If
'setting cursor and open information for recordset table
With BM2000MAY2
.ActiveConnection = BillingDB
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Source = "select * from BM2000MAY2 order by ClientNumber"
End With
End Function

I don't understand why I can't close the recordset. I have made the recorset function on a public module, and only call it out instead of coding it throught the entire program. As I open and close it in many areas.

Please someone help me.

the Darthmoob
Sign In or Register to comment.