Recordsets and Subforms

  • Thread starter Thread starter MichaelJohnson168
  • Start date Start date
M

MichaelJohnson168

I have a form that has a subform. They are joined by the OrderID. I am
trying to access the itemized records that are in the subfrom by
cloning the subform records.

I am getting errors on the method below.

Attempting to open a recordset using the subform
 
Hi,

use the format below

Dim rs As Recordset
Set rs = Forms![I Ph Orders]![I Ph Orders Subform].Form.RecordsetClone

give it a go, post back here if you are still having problems.


Regards

Alex
 
Tried it but got the following error below:

---------------------------
Run-time Error '13'

Type Mismatch
---------------------------


I also tried an alternate method by using the recordset open method on
a query in order to get at the subform records using the code below:

Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset

Set cn = CurrentProject.Connection

rs.Open ("OrderItemizedQuery"), cn

But got the error below:
-----------------------------------
Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE',
'SELECT', OR 'UPDATE'.
-----------------------------------

The "OrderItemizedQuery" uses the OrderID from the host form "I Ph
Orders".

OrderItemizedQuery
-----------------------------
SELECT [I Ph Orders].OrderID, [I Ph Order Details
Extended].ProductTitle, [I Ph Order Details Extended].Quantity
FROM [I Ph Order Details Extended] INNER JOIN [I Ph Orders] ON [I Ph
Order Details Extended].OrderID = [I Ph Orders].OrderID
WHERE ((([I Ph Orders].OrderID)=[Forms]![I Ph Orders]![OrderID]));
 
Hi,

I have just run the following, I have a form called form1, and a
subform called Candidate_Contact_History, it cloned perfectly.

Dim test As dao.Recordset
Set test = Forms!form1!CANDIDATE_CONTACT_HISTORY.Form.RecordsetClone

test.MoveFirst


I would like to add the use of forms/controls etc with spaces in them
works but makes things more dificult to read and you have to use []
around them, try to use _ like first_name rather than [first name] it
will make your life easer in the long run. If you still have problems
post back here and I will try some more things for you.


Regards

Alex
 
Back
Top