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

Assign a Offline Recordset to SubForm

Status
Not open for further replies.

kimbuya

Programmer
May 13, 2003
2
DE
Hello,
I created a ADO.Recordset and set fields. After it, I tried to fill my recordset.

Now, I want to assign this recordset a Subform
(in Access 2000).
But I got a exception "7965: ... Ungültiges Objekt ..."
means like invalid object.
I attach for this purpose a sample code.

-----------SAMPLE-------------------

'Create a offline Recordset
Set myRS = New ADODB.Recordset
With myRS
.ActiveConnection = Nothing
.CursorLocation = adUseClient
.LockType = adLockBatchOptimistic
End With

'insert a Field
myRS.Fields.Append "CITY", adVarChar, 20, adFldMayBeNull

'Open recordset
myRS.Open

'Fill recordset
myRS.AddNew
myRS.Fields("CITY").Value = "Berlin"
myRS.AddNew
myRS.Fields("CITY").Value = "Frankfurt"

'try to assign recordset raises an exception
Set Form_Formular3.Recordset = myRS '<-raises exception

--------------------------------------------------------
What is wrong here?

Thanks!

 
myRS.AddNew

myRS.Fields(&quot;CITY&quot;).Value = &quot;Berlin&quot;

myRS.Fields(&quot;CITY&quot;).Value = &quot;Frankfurt&quot;

myRS.update

I do not know if this will fix your problem but it is required
 
Thanks for usefull information. Now, after I addNew Records, I update my (offline) Recordset.

I cann fill my selfmade ADODB.Recordset correct. But the exception is permanent the same, if I wannt to assign it
to a Access form.

Set Form_myform.Recordset=myRs <--- EXCEPTION!!!
-----------------------------------------------
-----------SAMPLE-------------------

'Create a offline Recordset
Set myRS = New ADODB.Recordset
With myRS
.ActiveConnection = Nothing
.CursorLocation = adUseClient
.LockType = adLockBatchOptimistic
End With

'insert a Field
myRS.Fields.Append &quot;CITY&quot;, adVarChar, 20, adFldMayBeNull

'Open recordset
myRS.Open

'Fill recordset
myRS.AddNew
myRS.Fields(&quot;CITY&quot;).Value = &quot;Berlin&quot;
myRs.Update
myRS.AddNew
myRS.Fields(&quot;CITY&quot;).Value = &quot;Frankfurt&quot;
myRs.Update

'try to assign recordset on a form raises an exception
Set Form_Formular3.Recordset = myRS '<-raises exception
--------------------------------------------------------

Yours sincerely
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top