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
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