Copying data across

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

Eric

Hi,

This isn't exact code, but it's basically what should be
done:

-------------------------
Dim rstTemp, rstTemp1 As Recordset
Dim sqlTemp As String

rstTemp = Forms!MainForm.RecordsetClone
rstTemp.Move Forms!MainForm.Bookmark
rstTemp.MovePrevious

sqlTemp = "SELECT * FROM SUBTABLE WHERE FOREIGN_KEY = "
& rstTemp!primaryKey
Set rstemp1 = CurrentDb.OpenRecordset(sqlTemp)

If rstTemp1.RecordCount > 0 Then
rstTemp1.MoveFirst
txtField1 = rstTemp!field1
txtField2 = rstTemp!field2
'ETC, ETC, ETC
End If

rstTemp.Close
rstTemp1.Close
------------------------------

Like I said, some of the syntax will have to be fixed, but
it should be accurate enough for you to understand.

I hope this helps.

Regards,
Eric
 
Hi Eric

Thanks for that code, just a few questions.
Do i put this code into a onclick event for a button?
The txtField1 = rstTemp!field1 do I just change the
txtField1 to the name of the field where the data is being
copied from and do I use the primary key field aswell.

Again thanks for your help.
Kind Regards
Asif
 
Hey Asif,

Yeah you can put this code in the onclick section of the
button.

txtField1 is the text box where you want the content of
the temporary recordset field to go, so like you said just
change txtField1 to the name of you textbox.

I don't understand what you mean by "do I use the primary
key aswell"? Please clarify.

Regards,
Eric
 
Back
Top