lookup data from other form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there,

I have two forms for data entry, they have same field name of "quotation" &
"salary", when I enter data in "quotation" (after update event), I want the
data in "salary" lookup the data from other form itself, I try to write a
code but does not work, could you please send me a code for reference? Thanks
very much!
 
Andy said:
Hi there,

I have two forms for data entry, they have same field name of "quotation" &
"salary", when I enter data in "quotation" (after update event), I want the
data in "salary" lookup the data from other form itself, I try to write a
code but does not work, could you please send me a code for reference? Thanks
very much!

Andy,

You don't give much information to work with. You can see your tables, forms
and data... we can't. So you need to be more specific.

So I am not sure what you want to do. I know you have two forms. Are both forms
open?

There are (at least) two controls on each form. When you enter something in a
"quotation" control, you want something looked up using the "salary" control:
on which form? And you want the data placed where?


Also, there is a terminology problem.

Forms have controls (combo boxes, list boxes, text boxes,...)
A form can be unbound or bound to a table or query ; controls can be unbound or
bound to a field in the form record source.

Tables have fields. Fields store the data.


So, are the two data entry forms bound or unbound? If bound what are the table
(or query) names?

Both forms have two controls. Are the controls bound or unbound? If bound, what
are the controls sources (what fields are the controls bound to)?


HTH
 
Hi Steve,

Sorry to make you confuse.

Actually, I want to write a code to accomplish below action.

The code as below but I thought it's not good :

Private Sub CUSTOMER_ID_AfterUpdate()

DoCmd.OpenForm "order lookup"
Me.[TEL] = Forms![ORDER LOOKUP]![TEL]
DoCmd.Close

End Sub

So I try to write another code as below but fail, appreciate please advise,
thanks!

Private Sub CUSTOMER_ID_AfterUpdate()

Dim qdf As QueryDef
Dim rst As Recordset
Dim db As Database

Set db = CurrentDb
Set qdf = db.QueryDefs("order lookup")
'query with criteria of [forms]![order]![customer ID]
Set rst = qdf.OpenRecordset

Me.TEL = rst.TEL

rst.Close

End Sub
 
Andy said:
Hi Steve,

Sorry to make you confuse.

Actually, I want to write a code to accomplish below action.

The code as below but I thought it's not good :

Private Sub CUSTOMER_ID_AfterUpdate()

DoCmd.OpenForm "order lookup"
Me.[TEL] = Forms![ORDER LOOKUP]![TEL]
DoCmd.Close

End Sub

So I try to write another code as below but fail, appreciate please advise,
thanks!

Private Sub CUSTOMER_ID_AfterUpdate()

Dim qdf As QueryDef
Dim rst As Recordset
Dim db As Database

Set db = CurrentDb
Set qdf = db.QueryDefs("order lookup")
'query with criteria of [forms]![order]![customer ID]
Set rst = qdf.OpenRecordset

Me.TEL = rst.TEL

rst.Close

End Sub

Andy,

Why do you think you need to write any code? If the two forms are bound to the
same table (or query), any control that is bound to the "TEL" *field* will
display the telephone number.


Please post the record source for each of the two forms.
 
Back
Top