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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The call open function

Status
Not open for further replies.

samuelsisgay

Programmer
Apr 17, 2002
4
0
0
AU
I'm still having trouble with that block of code...thanx for the syntax problem. I keep getting an error with the call rst1.Open line. I've opened the record

ERROR:The operation requested by the application is not allowed if the object is open.

I have accessed another table within the database within the form using the call procedure and openconnection.
This may be why it is reading as already open...

Anyway, the code is below...

MsgBox "record user results"
Call rst1.Open("SELECT * FROM results where username ='" & okUsername & "' and password ='" & okPassword & "'", cnn, adOpenKeyset, adLockOptimistic)
With rst1
.Fields("Trial1Correct").Value = txtCorrect.Text
.Fields("NoQuestions1").Value = txtTotal.Text
.Update
End With

Thanks
 
Try using the Database "OpenRecordSet" method instead of the record set's Open method. This should throw away the old (open) RecordSet entirely and start with a fresh one:

Code:
SET rst1 = db.OpenRecordSet("SELECT * FROM results where username ='" & okUsername & "' and password ='" & okPassword & "'", cnn, adOpenKeyset, adLockOptimistic)

(ps. "CALL" isn't necessary when calling an object's method, as in:
Code:
CALL rst1.Open( .... )
'More OOP-appearing:
rst1.Open( .... )
 
It appears that you are using ADO in which case there is not an OpenRecordset method.

The reason you are getting this error is because the recordset is already open.

Add this code before you go to use the Open method of the recordset.

If rst1.State = adOpen then
rst1.Close
End if

rst1.Open ....

this should fix your problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top