Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Problem with ADO Connection

darthmoobeydarthmoobey Posts: 140Member
Hello,

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.

[code]
If Val(DateDay) <= 531 And Val(DateDay) >= 516 Then
Open_2000MAY2
BM2000MAY2.MoveFirst
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
[/code]

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

[code]
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"
.Open
End With
End Function
[/code]

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.