Carry data across (Help)

  • Thread starter Thread starter Eric
  • Start date Start date
E

Eric

Asif,

This is the code that works correctly (because it was
tested)

----------------------------------------------
Dim rsttemp As Recordset
Dim rsttemp1 As Recordset
Dim sqlTemp As String

Set rsttemp = Forms!master.RecordsetClone
rsttemp.Bookmark = Forms!master.Bookmark
rsttemp.MovePrevious

sqlTemp = "SELECT * FROM test2 WHERE
theForeignKeyofTheSubTable=" & rsttemp!
thePrimaryKeyofTheMasterTable & ";"
Set rsttemp1 = CurrentDb.OpenRecordset(sqlTemp)

If rsttemp1.RecordCount > 0 Then
rsttemp.MoveFirst
Me.txt1 = rsttemp1!field1
Me.txt2 = rsttemp1!field2
End If
rsttemp.Close
rsttemp1.Close
------------------------------------------------
Make sure you have the appropriate references. This code
requires the DAO reference to be used before ADO. So
prioritize your references accordingly.

Also, replace all control names with names that are used
by your database. "theForeignKeyofTheSubTable"
& "thePrimaryKeyofTheMasterTable" in the sqlTemp string
must be replaced with your foreign and primary keys.

Hope this helps, but please let me know if this doesn't
make sense.

Regards,
Eric
 
Asif,

Yeah those look like they should work. I would however put
the OLE lib just after the Access 10.0 lib.

That's the order I had when I created my tresting
environment, and it worked fine.
 
Hi Eric

Tried that still the same error. I don't think it should
matter but I am using access 2002 and I have created a
access project. Is there anything else I should try?.

Asif
 
Hi Asif,

Actually running a adp does make a big difference. I will
modify the code to run it using ADO.
 
Asif,

Alright... you should be god to go now. Just do the usual
changes, compile and run.

---------------------------------------------
Dim rsttemp As ADODB.Recordset
Dim rsttemp1 As ADODB.Recordset
Dim sqlTemp As String

Set rsttemp = Forms!master.RecordsetClone
rsttemp.Bookmark = Forms!master.Bookmark
rsttemp.MovePrevious

sqlTemp = "SELECT * FROM test2 WHERE someFor = " &
rsttemp!somePri & ";"
Set rsttemp1 = New ADODB.Recordset
rsttemp1.Open sqlTemp, CurrentProject.Connection,
adOpenStatic

If rsttemp1.RecordCount > 0 Then
rsttemp.MoveFirst
Me.txt1 = rsttemp1!field1
Me.txt2 = rsttemp1!field2
End If
rsttemp.Close
rsttemp1.Close
-------------------------------------------

All I suggest you do now is set the ADO lib reference
priority back to being before DAO.

Hope this works. Let me know if you have anymore problems.

Best Regards,
Eric
 
Asif,

If there is no confidential information on your database,
would you mind sending it to me through e-mail. I'll take
a look at it. That's a very strange error.
 
Back
Top