Transfering data between forms

K

Kat

I have the main form (tradeinfo) that has a field (tradeid) that has a
tracking number for the contact information for that trade. Then I have a
diffrent form (compperform) that store diffrent information for each trade.
How can I transfer the tracking number to the second form?
 
D

Dale Fye

Kat,

The OpenForm method has a parameter (WhereCondition) which will filter the
recordset of the second form. I'll assume you have a button on the
tradeinfo form that opens the compperform form. If this is the case, the
code to open the second form to the record identified by the value in the
[tradeid] field is:

Private Sub cmd_Button_Click()

docmd.OpenForm "compperform", , ,"[tradeid] = " & me.tradeid

End sub

This assumes that the field [tradeid] is also the name of the control, and
that the value in that field is a numeric value. If it is a string, I would
write it as:

docmd.OpenForm "compperform", , ,"[tradeid] = " & chr$(34) & me.tradeid
& chr$(34)

HTH
Dale
 
Top