Use the AfterUpdate event procedure of the product code box to DLookup() the
product name and assign it to the text field you have for this purpose.
This kind of thing:
Private Sub ProductCode_AfterUpdate()
Dim strWhere As String
If Not IsNull(Me.ProductCode) Then
strWhere = "[ProductCode] = " & Me.ProductCode
Me.[Descrip] = DLookup("ProductName", "tblProduct", strWhere)
End If
End Sub
If ProductCode is a text field (not a Number field), you need extra quotes:
strWhere = "[ProductCode] = """ & Me.ProductCode & """"
Explanation:
http://allenbrowne.com/casu-17.html
For more help with DLookup(), see:
http://allenbrowne.com/casu-07.html
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Reply to group, rather than allenbrowne at mvps dot org.
leungkong said:
Hi Jeanette,
yes, product database is an access database.
actually, i want to make a invoice worksheet.
for the user, if the worksheet show
Code: 1 qty: 100 unit price: USD 2
it is not easy to understand what the goods is.
since the product name always need to change as per customer request
(customs problem, to avoid some word to save the tax)
so, i want to call the product name from the product database for
reference.
product can be revised by user before update to invoice database